Replies: 1 comment 4 replies
-
|
The main issue is that You need each column to be some subtype of const columns: Column<Data>[] = [
{ accessor: 'value', header: 'Value' }, // this is a general `Column<Data>`
];Fortunately for you, TypeScript 4.9 came up with the new const columns = [
{ accessor: 'value', header: 'Value' },
{
accessor: 'date',
header: 'Date',
cell: ({ value }: { value: Date }) => value.toLocaleString()
}
] satisfies Column<Data>[]; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. I've created a data grid component, it has
columnsprop of this type:I tried to use it but noticed that
Columntype doesn't have many properties thattable.columnaccepts. When I create a columns like that:I get TS error near
accessorproperty that tells me "Object literal may only specify known properties, and 'accessor' does not exist in type 'Column<Data, AnyPlugins>'"I tried to use another type provided by the library --
DataColumnInit:, but I encountered another set of setbacks, like
cellfunction not knowing the type of the value.Does anyone have an example of a reusable datagrid component in typescript? Or an advice how to achieve reusability?
Beta Was this translation helpful? Give feedback.
All reactions