Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Why are filterFns and aggregationFns required in tableOption? #4926

Unanswered
sp88011 asked this question in Q&A
Discussion options

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> = ( ...
You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

Same, and it's annoying
can I not declare modules locally for one file?

You must be logged in to vote
0 replies
Comment options

For future visitors. Just found out two things:

  1. Interfaces defined inside the declare module (appear to) become obligatory in all tables.
  2. 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>,
 }),
You must be logged in to vote
2 replies
Comment options

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?

Comment options

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /