Typescript error in useFilter hook from Query Router Search Params example #5812
Open
Description
opened on Nov 20, 2024
TanStack Table version
8.20.5
Framework/Library version
18.3.1
Describe the bug and the steps to reproduce it
In this example of using Tanstack Router search params via a useFilters hook, there are some type errors when patching the param values.
Type '(prev: { pageIndex?: number | undefined; id?: number | undefined; firstName?: string | undefined; lastName?: string | undefined; age?: number | undefined; pageSize?: number | undefined; sortBy?: `${string}.asc` | ... 1 more ... | undefined; foo?: string | undefined; bar?: number | undefined; }) => { ...; } & Partial...' is not assignable to type 'true | ParamsReducerFn<Router<RootRoute<undefined, {}, AnyContext, AnyContext, {}, undefined, RootRouteChildren, FileRouteTypes>, TrailingSlashOption, boolean, Record<...>, Record<...>>, "SEARCH", string, string | undefined> | undefined'.
Type '(prev: { pageIndex?: number | undefined; id?: number | undefined; firstName?: string | undefined; lastName?: string | undefined; age?: number | undefined; pageSize?: number | undefined; sortBy?: `${string}.asc` | ... 1 more ... | undefined; foo?: string | undefined; bar?: number | undefined; }) => { ...; } & Partial...' is not assignable to type 'ParamsReducerFn<Router<RootRoute<undefined, {}, AnyContext, AnyContext, {}, undefined, RootRouteChildren, FileRouteTypes>, TrailingSlashOption, boolean, Record<...>, Record<...>>, "SEARCH", string, string | undefined>'.
Type '{ pageIndex?: number | undefined; id?: number | undefined; firstName?: string | undefined; lastName?: string | undefined; age?: number | undefined; pageSize?: number | undefined; sortBy?: `${string}.asc` | ... 1 more ... | undefined; foo?: string | undefined; bar?: number | undefined; } & Partial<...>' is not assignable to type 'never'.(2322)
link.d.ts(62, 5): The expected type comes from property 'search' which is declared here on type 'NavigateOptions<Router<RootRoute<undefined, {}, AnyContext, AnyContext, {}, undefined, RootRouteChildren, FileRouteTypes>, TrailingSlashOption, boolean, Record<...>, Record<...>>, string, string | undefined, string, "">'
(property) MakeOptionalSearchParams<Router<RootRoute<undefined, {}, AnyContext, AnyContext, {}, undefined, RootRouteChildren, FileRouteTypes>, TrailingSlashOption, boolean, Record<...>, Record<...>>, string, string | undefined>.search?: true | ParamsReducerFn<Router<RootRoute<undefined, {}, AnyContext, AnyContext, {}, undefined, RootRouteChildren, FileRouteTypes>, TrailingSlashOption, boolean, Record<...>, Record<...>>, "SEARCH", string, string | undefined> | undefined```
### Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/github/tanstack/table/tree/main/examples/react/query-router-search-params?embed=1&theme=dark&preset=node&file=src/main.tsx
### Screenshots or Videos (Optional)
_No response_
### Do you intend to try to help solve this bug with your own PR?
No, because I do not know how
### 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.
Metadata
Assignees
Labels
No labels
Activity