mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 03:22:59 +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 {
|
interface TableInterface extends InternalTableType {
|
||||||
|
defaultProps?: Partial<TableProps<any>>;
|
||||||
SELECTION_ALL: 'SELECT_ALL';
|
SELECTION_ALL: 'SELECT_ALL';
|
||||||
SELECTION_INVERT: 'SELECT_INVERT';
|
SELECTION_INVERT: 'SELECT_INVERT';
|
||||||
SELECTION_NONE: 'SELECT_NONE';
|
SELECTION_NONE: 'SELECT_NONE';
|
||||||
@ -529,7 +532,7 @@ interface TableInterface extends InternalTableType {
|
|||||||
Summary: typeof Summary;
|
Summary: typeof Summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Table = TableRef as TableInterface;
|
const Table = ForwardTable as TableInterface;
|
||||||
|
|
||||||
Table.defaultProps = {
|
Table.defaultProps = {
|
||||||
rowKey: 'key',
|
rowKey: 'key',
|
||||||
|
@ -28,6 +28,14 @@ describe('Table.typescript', () => {
|
|||||||
const table = <Table rowSelection={{ selections: [Table.SELECTION_ALL] }} />;
|
const table = <Table rowSelection={{ selections: [Table.SELECTION_ALL] }} />;
|
||||||
expect(table).toBeTruthy();
|
expect(table).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('generic', () => {
|
||||||
|
interface RecordType {
|
||||||
|
key: string;
|
||||||
|
}
|
||||||
|
const table = <Table<RecordType> dataSource={[{ key: 'Bamboo' }]} />;
|
||||||
|
expect(table).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Table.typescript types', () => {
|
describe('Table.typescript types', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user