router icon indicating copy to clipboard operation
router copied to clipboard

navigate({ search }) TypeScript error in beta.25

Open MarkLyck opened this issue 2 years ago • 3 comments

Describe the bug

After upgrading to beta.25 all uses of navigate({ search }) now results in the following TS error:

Type 'any' is not assignable to type 'never'.

example:

navigate({
      search: (old) => ({
        ...old,
        resource: newResource,
        selected: undefined,
      }),
      replace: true,
    })

Your Example Website or App

see example above, let me know if you need a StackBlitz

Steps to Reproduce the Bug or Issue

Screen Shot 2022-11-19 at 11 48 44

Note this happens both with useNearestMatch() and useMatch(route.id)

Expected behavior

Should not cause TS error

Screenshots or Videos

No response

Platform

"@tanstack/react-router": "0.0.1-beta.25",

Additional context

No response

MarkLyck avatar Nov 19 '22 16:11 MarkLyck

A stackblitz would be great.

tannerlinsley avatar Nov 19 '22 17:11 tannerlinsley

@tannerlinsley Sorry this was my bad, I had an outdated node_modules. Wiped everything and it works with useMatch now.

I can still reproduce an issue but only with useNearestMatch() now, which I imagine is the same problem as https://github.com/TanStack/router/issues/372

Here's a stackblitz where search gives a TypeScript error for useNearestMatch()

https://stackblitz.com/edit/tanstack-router-af8ox9?file=src/main.tsx

MarkLyck avatar Nov 19 '22 18:11 MarkLyck

So can search be empty?

StringKe avatar Nov 25 '22 14:11 StringKe

I believe you should have a much better experience now. Give it a shot!

tannerlinsley avatar Dec 07 '22 21:12 tannerlinsley