Skip to content

Commit

Permalink
feat: add DataIndexExtendProps
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Apr 2, 2024
1 parent 3fc8cbd commit 2bb7e69
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EXPAND_COLUMN, INTERNAL_HOOKS } from './constant';
import { FooterComponents as Summary } from './Footer';
import type { ColumnType, ColumnsType, Reference } from './interface';
import type { ColumnType, ColumnsType, DataIndexExtendProps, Reference } from './interface';
import Column from './sugar/Column';
import ColumnGroup from './sugar/ColumnGroup';
import type { TableProps } from './Table';
Expand All @@ -24,6 +24,7 @@ export {
type Reference,
type ColumnType,
type ColumnsType,
type DataIndexExtendProps,
};

export default Table;
8 changes: 5 additions & 3 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ export interface RenderedCell<RecordType> {

export type Direction = 'ltr' | 'rtl';

// SpecialString will be removed in antd@6
export type SpecialString<T> = T | (string & {});
// DataIndex type expansion
export interface DataIndexExtendProps {
// more?:string
}

export type DataIndex<T = any> = DeepNamePath<T> | SpecialString<T> | number | (SpecialString<T> | number)[];
export type DataIndex<T = any> = DeepNamePath<T & DataIndexExtendProps>;

export type CellEllipsisType = { showTitle?: boolean } | boolean;

Expand Down
11 changes: 11 additions & 0 deletions tests/nameTypeCheck.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ type FieldType = {
e?: { e1?: { e2?: string; e3?: string[]; e4: { e5: { e6: string } } } };
list?: { age?: string }[];
};
declare module '../src/index' {
export interface DataIndexExtendProps {
more?: string;
}
}

describe('nameTypeCheck', () => {
it('type inference', () => {
Expand Down Expand Up @@ -38,4 +43,10 @@ describe('nameTypeCheck', () => {
);
console.log('table', table);
});
it('DataIndexExtendProps', () => {
const table = (
<Table<{ name?: string }> columns={[{ dataIndex: 'name' }, { dataIndex: 'more' }]} />
);
console.log('table', table);
});
});

0 comments on commit 2bb7e69

Please sign in to comment.