Incorrect example for custom column metadata declaration file
Describe the bug
If I create tanstack-table.d.ts file under types/ folder, it doesn't work and column meta is still not typed (it is of type unknown to be precise`)
Your minimal, reproducible example
https://tanstack.com/table/v8/docs/api/core/column-def#meta
Steps to reproduce
- Follow the example https://tanstack.com/table/v8/docs/api/core/column-def#meta
- Use
declare module '@tanstack/table-core' {
interface ColumnMeta {
// filterType: CustomFilterType | StandardFilterType;
className: string;
}
}
Expected behavior
types should work and column.meta should be typed, with className property.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
MacOS
react-table version
^8.10.7
TypeScript version
5.1.3
Additional context
It all works fine if I change it to this:
declare module '@tanstack/react-table' {
interface ColumnMeta {
// filterType: CustomFilterType | StandardFilterType;
className: string;
}
}
So could be jsut a mistake in documentation?
Terms & Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
~UPD: it seems to fix the problem during runtime, but not during build time.~ ~When building the app, it gives~
Property 'className' does not exist on type 'ColumnMeta<TableData, unknown>'.
It was related to the project structure. But I guess making this work for monorepo setup with smth like nx, will be a pain. Becaue you'll need to include types file into your tsconfig.json in app/ and then in every lib where you use table.
@tar-aldev I got the same issue. How do you include the types file in tsconfig?
@tar-aldev I got the same issue. How do you include the types file in tsconfig?
@tar-aldev ?
So, there was an nx lib called table, there I had a file called tanstack-table.d.ts. Like this
table/
-- src/
---- types/
------ tanstack-table.d.ts
So for that lib it works already.
For all other libs, I added this into tsconfig.lib.json
So e.g. there is another lib users like
users/
-- tsconfig.lib.json
// tsconfig.lib.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts",
"next",
"@nx/next/typings/image.d.ts"
]
},
"exclude": [
...
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx", "../../../table/src/types"]
}
As I said, it's far from perfect, but I couldn't find a better way.
Don't use table core. Specify which framework adapter you have installed.