Skip to content

Refine typing for Column #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,17 +602,17 @@ export interface Column {
/**
* Can be a string to set one row high header or an array to set multi-row high header
*/
header: string | string[];
header?: string | string[];

/**
* The name of the properties associated with this column in each row
*/
key: string;
key?: string;

/**
* The width of the column
*/
width: number;
width?: number;

/**
* Set an outline level for columns
Expand Down Expand Up @@ -644,12 +644,16 @@ export interface Column {
readonly headers: string[];
readonly isDefault: boolean;
readonly headerCount: number;
border: Partial<Borders>;
fill: Fill;
numFmt: string
font: Partial<Font>;
alignment: Partial<Alignment>;
protection: Partial<Protection>;

/**
* Below properties read from style
*/
border?: Partial<Borders>;
fill?: Fill;
numFmt?: string;
font?: Partial<Font>;
alignment?: Partial<Alignment>;
protection?: Partial<Protection>;

toString(): string
equivalentTo(other: Column): boolean
Expand Down Expand Up @@ -1134,18 +1138,18 @@ export interface Worksheet {
*/
readonly actualColumnCount: number;

getColumnKey(key: string): Partial<Column>;
getColumnKey(key: string): Column;

setColumnKey(key: string, value: Partial<Column>): void;
setColumnKey(key: string, value: Column): void;

deleteColumnKey(key: string): void;

eachColumnKey(callback: (col: Partial<Column>, index: number) => void): void;
eachColumnKey(callback: (col: Column, index: number) => void): void;

/**
* Access an individual columns by key, letter and 1-based column number
*/
getColumn(indexOrKey: number | string): Partial<Column>;
getColumn(indexOrKey: number | string): Column;

/**
* Cut one or more columns (columns to the right are shifted left)
Expand All @@ -1166,7 +1170,7 @@ export interface Worksheet {
* Note: these column structures are a workbook-building convenience only,
* apart from the column width, they will not be fully persisted.
*/
columns: Array<Partial<Column>>;
columns: Array<Column>;

/**
* The total row size of the document. Equal to the row number of the last row that has values.
Expand Down