router icon indicating copy to clipboard operation
router copied to clipboard

invalid type inference for loader data of a route instantiated with createRootRouteWithContext

Open adrtivv opened this issue 1 year ago • 0 comments

Describe the bug

Type inference doesn't work for loader data returned from useLoaderData() method call on a route instantiated with createRootRouteWithContext().

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-xjbcqb?file=src%2Froutes%2F__root.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the reproduction url, open the file at src/routes/__root.tsx.
  2. Compare the inferred types of variables data and data2 in the file.

Expected behavior

  1. Variable data2 should be of type { hello: string } and not unknown.

Screenshots or Videos

data is of the expected type { hello: string }

1

data2 is of unexpected type unknown

2

Platform

  • OS: Linux
  • Browser: Brave-Browser
  • Version: 1.15.7

Additional context

No response

adrtivv avatar Jan 31 '24 22:01 adrtivv