当我试图呈现一个定制的Ant设计表时,我遇到了这些错误:
semantic error TS2322: Type '{ columns: never[]; }' is not assignable to type
'IntrinsicAttributes & TableProps<any>'. Property 'columns' does not exist on
type 'IntrinsicAttributes & TableProps<any>'.
semantic error TS2322: Type '{ dataSource: never[]; columns: never[]; }' is not
assignable to type 'IntrinsicAttributes & TableProps<any>'. Property 'dataSource'
does not exist on type 'IntrinsicAttributes & TableProps<any>'.
Component(dataSource和clumns是空数组,但是当我添加任何对象值时也会出现同样的问题):
const DsrTable: FC = (): JSX.Element => {
return (
<div>
<h1>Table</h1>
<Table
dataSource={[]}
columns={[]}
/>
</div>
)
}
表格:
declare const UTable: (props: TableProps<any>) => JSX.Element;
TableProps:
export interface TableProps<T> extends AntdTableProps<T> {
mediaQueryLimit?: number;
}
和反表属性:
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'transformColumns' | 'internalHooks' | 'internalRefs' | 'data' | 'columns' | 'scroll' | 'emptyText'> {
dropdownPrefixCls?: string;
dataSource?: RcTableProps<RecordType>['data'];
columns?: ColumnsType<RecordType>;
pagination?: false | TablePaginationConfig;
loading?: boolean | SpinProps;
size?: SizeType;
bordered?: boolean;
locale?: TableLocale;
onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<RecordType> | SorterResult<RecordType>[], extra: TableCurrentDataSource<RecordType>) => void;
rowSelection?: TableRowSelection<RecordType>;
getPopupContainer?: GetPopupContainer;
scroll?: RcTableProps<RecordType>['scroll'] & {
scrollToFirstRowOnChange?: boolean;
};
sortDirections?: SortOrder[];
showSorterTooltip?: boolean | TooltipProps;
}
不幸的是,我不能改变任何表的属性和代码。我只能自定义DsrTable组件。
1条答案
按热度按时间xmd2e60i1#
好的,问题已经解决了。我正在使用节点vido14构建库。更改为16后,所有工作都像一个魅力。