T
TanStack3y ago
jolly-crimson

Typechecking overwritten ColumnMeta

I have extended the ColumnMeta type as described in https://tanstack.com/table/v8/docs/api/core/column-def#meta, which seems to give me correct autocompletion and typechecking when using column defs, but not when creating them. See: https://codesandbox.io/s/react-table-v8-forked-j74p00?file=/src/columns.tsx In this codesandbox, I have overwritten the types in extend-table-core.ts, and am creating a column definition using columnHelper in columns.tsx. When creating a column, I would expect meta: { foo: "bar" } to error because: a) foo is not part of the type that i'm using to overwrite ColumnMeta, and b) meta is missing multiple non-optional properties from my overwriting type But TypeScript does not throw an error about either of these issues. Is there a way to get TS to typecheck meta like this when creating columnDefs?
2 Replies
sensitive-blue
sensitive-blue3y ago
I have the same problem too
jolly-crimson
jolly-crimsonOP3y ago
In case you're still stuck on this: In the sandbox linked in my post I try to overwrite the type using type ColumnMeta<...> = ..., but that doesn't work because the type is defined as an interface in the original code, so you have to overwrite it as an interface aswell: interface ColumnMeta<...> {}

Did you find this page helpful?