-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
-
Pretty sure this is a pure Typescript problem/misunderstanding (...what isn't :) ? ) but I'm struggling to figure out the root cause.
I created a custom filter and custom aggregation function.
Now, for some reason, my table options require me to provide the filterFns
and aggregationFns
properties even though I'm not doing any filtering or aggregation in my table.
What can I do to not have to provide those properties?
const table = useReactTable({ data, columns,
//etc.
Getting a type error that reads:
Property 'aggregationFns' is missing in type '{ data: (....)}'
...
Grouping.d.ts(53, 5): 'aggregationFns' is declared here.
In another file, I define my custom filter and aggregation function
declare module "@tanstack/table-core" {
interface FilterFns {
fuzzy: FilterFn<unknown>;
}
interface FilterMeta {
itemRank: RankingInfo;
}
interface AggregationFns {
progress: AggregationFn<unknown>;
}
}
export const fuzzyFilter: FilterFn<any> = ...
export const progressAggregator: AggregationFn<any> = ( ...
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 2 replies
-
Same, and it's annoying
can I not declare modules locally for one file?
Beta Was this translation helpful? Give feedback.
All reactions
-
For future visitors. Just found out two things:
- Interfaces defined inside the
declare module
(appear to) become obligatory in all tables. - If you need to apply a filter on e.g. just a specific table and a specific column there is no need to use
declare module
. Instead, just import your filter then add it to using the column helper like below:
import { permissionFilter } from "#app/components/tanstack-table/filters/permission"; ... columnHelper.accessor("action", { header: "Permission", enableColumnFilter: true, cell: (info) => info.getValue(), filterFn: permissionFilter as FilterFnOption<unknown>, }),
Beta Was this translation helpful? Give feedback.
All reactions
-
🚀 1
-
wow you're a fucking legend dude
I was struggling with typings till the moment, I still use the library
How did you find out the solution?
Beta Was this translation helpful? Give feedback.
All reactions
-
- nterfaces defined inside the
declare module
(appear to) become obligatory in all tables.- If you need to apply a filter on e.g. just a specific table and a specific column there is no need to use
declare module
. Instead, just import your filter then add it to using the column helper like below:
You're invited to my wedding. Thanks dude
Beta Was this translation helpful? Give feedback.