mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
fix: Table ts define (#20695)
This commit is contained in:
parent
7d95365183
commit
6017b3f025
17
components/table/Column.tsx
Normal file
17
components/table/Column.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
import { ColumnType } from './interface';
|
||||
|
||||
export interface ColumnProps<RecordType> extends ColumnType<RecordType> {
|
||||
children?: null;
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
/**
|
||||
* This is a syntactic sugar for `columns` prop.
|
||||
* So HOC will not work on this.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function Column<RecordType>(_: ColumnProps<RecordType>) {
|
||||
return null;
|
||||
}
|
||||
|
||||
export default Column;
|
20
components/table/ColumnGroup.tsx
Normal file
20
components/table/ColumnGroup.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import { ColumnType } from './interface';
|
||||
import { ColumnProps } from './Column';
|
||||
|
||||
export interface ColumnGroupProps<RecordType> extends Omit<ColumnType<RecordType>, 'children'> {
|
||||
children:
|
||||
| React.ReactElement<ColumnProps<RecordType>>
|
||||
| React.ReactElement<ColumnProps<RecordType>>[];
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
/**
|
||||
* This is a syntactic sugar for `columns` prop.
|
||||
* So HOC will not work on this.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function ColumnGroup<RecordType>(_: ColumnGroupProps<RecordType>) {
|
||||
return null;
|
||||
}
|
||||
|
||||
export default ColumnGroup;
|
@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import RcTable, { Column, ColumnGroup } from 'rc-table';
|
||||
import RcTable from 'rc-table';
|
||||
import { TableProps as RcTableProps, INTERNAL_HOOKS } from 'rc-table/lib/Table';
|
||||
import Spin, { SpinProps } from '../spin';
|
||||
import Pagination, { PaginationConfig } from '../pagination';
|
||||
@ -29,6 +29,8 @@ import renderExpandIcon from './ExpandIcon';
|
||||
import scrollTo from '../_util/scrollTo';
|
||||
import defaultLocale from '../locale/en_US';
|
||||
import SizeContext, { SizeType } from '../config-provider/SizeContext';
|
||||
import Column from './Column';
|
||||
import ColumnGroup from './ColumnGroup';
|
||||
|
||||
export { ColumnsType, TablePaginationConfig };
|
||||
|
||||
|
24
components/table/__tests__/type.test.tsx
Normal file
24
components/table/__tests__/type.test.tsx
Normal file
@ -0,0 +1,24 @@
|
||||
/* eslint-disable no-unused-expressions */
|
||||
|
||||
import * as React from 'react';
|
||||
import Table from '../Table';
|
||||
|
||||
const { Column, ColumnGroup } = Table;
|
||||
|
||||
describe('Table.typescript', () => {
|
||||
it('Column', () => {
|
||||
<Table>
|
||||
<Column dataIndex="test" title="test" sorter />
|
||||
</Table>;
|
||||
});
|
||||
it('ColumnGroup', () => {
|
||||
<Table>
|
||||
<Column dataIndex="test" title="test" sorter />
|
||||
<ColumnGroup>
|
||||
<Column dataIndex="test" title="test" sorter />
|
||||
</ColumnGroup>
|
||||
</Table>;
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-enable */
|
Loading…
Reference in New Issue
Block a user