mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
fix: Table ts definition (#32358)
* fix: Table ts definition * fix: backof default rowKey
This commit is contained in:
parent
8ec15224d3
commit
ec9ecde052
@ -516,11 +516,14 @@ function InternalTable<RecordType extends object = any>(
|
||||
);
|
||||
}
|
||||
|
||||
const TableRef = React.forwardRef(InternalTable);
|
||||
const ForwardTable = React.forwardRef(InternalTable) as <RecordType extends object = any>(
|
||||
props: React.PropsWithChildren<TableProps<RecordType>> & { ref?: React.Ref<HTMLDivElement> },
|
||||
) => React.ReactElement;
|
||||
|
||||
type InternalTableType = typeof TableRef;
|
||||
type InternalTableType = typeof ForwardTable;
|
||||
|
||||
interface TableInterface extends InternalTableType {
|
||||
defaultProps?: Partial<TableProps<any>>;
|
||||
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',
|
||||
|
@ -28,6 +28,14 @@ describe('Table.typescript', () => {
|
||||
const table = <Table rowSelection={{ selections: [Table.SELECTION_ALL] }} />;
|
||||
expect(table).toBeTruthy();
|
||||
});
|
||||
|
||||
it('generic', () => {
|
||||
interface RecordType {
|
||||
key: string;
|
||||
}
|
||||
const table = <Table<RecordType> dataSource={[{ key: 'Bamboo' }]} />;
|
||||
expect(table).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Table.typescript types', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user