Skip to content

Typescript error in useFilter hook from Query Router Search Params example #5812

Open
@tyschroed

Description

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.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions