fix: Table ts define (#20695)

This commit is contained in:
二货机器人 2020-01-06 17:28:28 +08:00 committed by GitHub
parent 7d95365183
commit 6017b3f025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 1 deletions

View 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;

View 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;

View File

@ -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 };

View 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 */