Skip to content
Source
Sign inSign up
TanStack/router

UseNavigate search functional syntax missing type errors #6264

Send to my agent
OpenMaskoe(GitHub profile, opens in a new tab) opened this issue 5 comments

Which project does this relate to?

Start

Describe the bug

If I use the functional syntax of the navigate function, it does not give me type safety for wrong parameters.

I would expect most people to use this syntax most of the time, when there are multiple url parameters.

Steps to Reproduce the Bug or Issue

https://stackblitz.com/edit/github-rdremnpn?file=src%2Froutes%2Findex.tsx

import { createFileRoute, Link } from '@tanstack/react-router'
import z from 'zod';

const paramsSchema = z.object({
  query: z.string().optional(),
});

export const Route = createFileRoute('/test')({
  validateSearch: paramsSchema,
  component: RouteComponent,
})

function RouteComponent() {
  const navigate = Route.useNavigate();

  const test = () => {
    navigate({ search: { query: "bro", lmao: "squiggly here" } })
    navigate({ search: (prev) => ({ ...prev, query: "bro", lmao: "no squiggly here", }) })
  }

  return <div>
    i cant find the syntax for links...
  </div>
}

Expected behavior

lmao gets marked as an error just as it does above

Platform

  • Router / Start Version: 1.145.0
  1. can you please provide a complete example project?

  2. schiller-manuel(GitHub profile, opens in a new tab) added labelsinformation needed

  3. I added the stackblitz, i thought it didnt have tanstack start yesterday, but it does

  4. i downloaded your example and ran locally, typescript error occurs as expected.

    Image
  5. On the first one yes. On the second one it doesnt.

  6. schiller-manuel(GitHub profile, opens in a new tab) removed labelsinformation needed

  7. This seems to be a limitation of TypeScript. typescript-issue-7547

Sign in to join this conversation.