Skip to content

Commit 2bb7e69

Browse files
committed
feat: add DataIndexExtendProps
1 parent 3fc8cbd commit 2bb7e69

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EXPAND_COLUMN, INTERNAL_HOOKS } from './constant';
22
import { FooterComponents as Summary } from './Footer';
3-
import type { ColumnType, ColumnsType, Reference } from './interface';
3+
import type { ColumnType, ColumnsType, DataIndexExtendProps, Reference } from './interface';
44
import Column from './sugar/Column';
55
import ColumnGroup from './sugar/ColumnGroup';
66
import type { TableProps } from './Table';
@@ -24,6 +24,7 @@ export {
2424
type Reference,
2525
type ColumnType,
2626
type ColumnsType,
27+
type DataIndexExtendProps,
2728
};
2829

2930
export default Table;

src/interface.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ export interface RenderedCell<RecordType> {
6767

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

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

73-
export type DataIndex<T = any> = DeepNamePath<T> | SpecialString<T> | number | (SpecialString<T> | number)[];
75+
export type DataIndex<T = any> = DeepNamePath<T & DataIndexExtendProps>;
7476

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

tests/nameTypeCheck.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ type FieldType = {
99
e?: { e1?: { e2?: string; e3?: string[]; e4: { e5: { e6: string } } } };
1010
list?: { age?: string }[];
1111
};
12+
declare module '../src/index' {
13+
export interface DataIndexExtendProps {
14+
more?: string;
15+
}
16+
}
1217

1318
describe('nameTypeCheck', () => {
1419
it('type inference', () => {
@@ -38,4 +43,10 @@ describe('nameTypeCheck', () => {
3843
);
3944
console.log('table', table);
4045
});
46+
it('DataIndexExtendProps', () => {
47+
const table = (
48+
<Table<{ name?: string }> columns={[{ dataIndex: 'name' }, { dataIndex: 'more' }]} />
49+
);
50+
console.log('table', table);
51+
});
4152
});

0 commit comments

Comments
 (0)