diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 3c9ef4db69a9..a4a02045370b 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -516,11 +516,14 @@ function InternalTable( ); } -const TableRef = React.forwardRef(InternalTable); +const ForwardTable = React.forwardRef(InternalTable) as ( + props: React.PropsWithChildren> & { ref?: React.Ref }, +) => React.ReactElement; -type InternalTableType = typeof TableRef; +type InternalTableType = typeof ForwardTable; interface TableInterface extends InternalTableType { + defaultProps?: Partial>; SELECTION_ALL: 'SELECT_ALL'; SELECTION_INVERT: 'SELECT_INVERT'; SELECTION_NONE: 'SELECT_NONE'; @@ -529,7 +532,7 @@ interface TableInterface extends InternalTableType { Summary: typeof Summary; } -const Table = TableRef as TableInterface; +const Table = ForwardTable as TableInterface; Table.defaultProps = { rowKey: 'key', diff --git a/components/table/__tests__/type.test.tsx b/components/table/__tests__/type.test.tsx index 6e854146dd74..c12e4937db0c 100644 --- a/components/table/__tests__/type.test.tsx +++ b/components/table/__tests__/type.test.tsx @@ -28,6 +28,14 @@ describe('Table.typescript', () => { const table = ; expect(table).toBeTruthy(); }); + + it('generic', () => { + interface RecordType { + key: string; + } + const table = dataSource={[{ key: 'Bamboo' }]} />; + expect(table).toBeTruthy(); + }); }); describe('Table.typescript types', () => {