How to properly type columns when using createColumnHelper? #5218
Unanswered
ronaldruzicka
asked this question in
Q&A
Replies: 1 comment 6 replies
-
If you're using the columnHelper to define your columns, in your case const columnHelper = createColumnHelper<Person>() you can afford to be more lax with the types in your columns type Props = {
columns: ColumnDef<Person, any>[];
data: Person[];
} |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, does anyone know how to properly type
columns
when table is extracted into it's own component? The type should beColumnDef
which is a union type where isAccessorColumnDef
which is a union type ofAccessorKeyColumnDef | AccessorFnColumnDef
..but in the end TS is showing an error, thataccessorKeyFn
is not used, because I'm usingaccessorKey
.The
Props
type for myTable
The error:
Here is CodeSandbox
I don't want to use type assertion for
columns
, but I don't see any other way.Any help appreciated🙏, thanks!
Beta Was this translation helpful? Give feedback.
All reactions