TS2339:打字稿中来自@type/react-table 的类型上不存在属性“Cell”

问题描述

我使用 @type/react-table 为我的表设置列,但我的 IDE 出现错误,抱怨 Cell 的类型不正确。我认为它是由 Cell@type/react-table 的可选类型引起的,我该如何解决这个问题?

//column.tsx
import {Column,Cell} from 'react-table';

export interface ColumnValue {
    [key: string]: any;
}
export type TableColumn = Column<ColumnValue>
export function createColumn(colDef: TableColumn): TableColumn {
  return colDef;
}
export const name = createColumn({
  id: 'name',Header: 'Name Column',Cell({value}}) {
    return value.hyperlink
  },});


//column.test.tsx
import {render} from '@testing-library/react';
import {name} from './Name';

describe('Test Name Column',() => {

  it('shows the name',() => {
    const {getByText} = render(
      name.Cell({
      // Error show TS2339: Property 'Cell' does not exist on type 'TableColumn'
        value: {hyperlink: 'asadasd'}}),})
    );
    expect(getByText('i am name')).toBeTruthy();
  });
});

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)