From ec9ecde05272eaeb8dc0b1fa72b9658907548926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Thu, 30 Sep 2021 11:43:42 +0800 Subject: [PATCH] fix: Table ts definition (#32358) * fix: Table ts definition * fix: backof default rowKey --- components/table/Table.tsx | 9 ++++++--- components/table/__tests__/type.test.tsx | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 3c9ef4db69..a4a0204537 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 6e854146dd..c12e4937db 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', () => {