TanStack / TanStack/router

The type of the "search" option in useNavigate is incorrect.

Open
#5,203 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Router

Describe the bug
import { NavigateOptions, useNavigate } from "@tanstack/react-router";

function Page() {
	const navigate = useNavigate();

	const option: NavigateOptions = { search: (prev: any) => prev }; // no type error

	navigate(option); // no type error
	navigate({ search: (prev: any) => prev }); //type error
}

Your Example Website or App

https://stackblitz.com/edit/github-9byjdyh7-rl6x81qz?file=src%2Froutes%2F__root.tsx

Steps to Reproduce the Bug or Issue

Paste the code above in VSCode

Expected behavior

No type errors

Screenshots or Videos
Image
Platform
  • Router / Start Version: [e.g. 1.132.2]
  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Browser Version: [e.g. 91.1]
  • Bundler: [e.g. vite]
  • Bundler Version: [e.g. 7.0.0]
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the snippet in VSCode and inspect the NavigateOptions and useNavigate type definitions. Compare the inferred types for the separately typed option and the inline search callback, then verify that both forms produce the intended, consistent type-checking result.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.