TanStackT
TanStack4y ago
5 replies
sacred-rose

Typescript issues

I have this props:

interface TableProps { columns: { title: string; id: string; }[]; rows: object[]; }
and I create my columns dynamically, like so:

const columnHelper = createColumnHelper<object>(); const columns = tableColumns.map(({ id, title }) => columnHelper.accessor(id, { header: title, cell: (data) => data.getValue(), }) );

The problem is that if I remove any of the following "any" types:

header: ({ table }: { table: any }) => ... cell: ({ row, getValue }: { row: any; getValue: any }) ... getSubRows: (row: any) => row.subRows, ...
Then I get the following error:
Member 'row' (the same for getValue or table) implicitly has an 'any' type


I have tried changing it to object and other React Table types but without success. Did someone have a similar issue? Am I creating the createColumnHelper method with the correct type according to my table props?

Thanks!
Was this page helpful?