TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.27k stars 495 forks source link

Generated router with TS errors using new `isolatedDeclarations` #1630

Open SimenB opened 2 weeks ago

SimenB commented 2 weeks ago

Describe the bug

Using isolatedDeclarations in the TypeScript 5.5 beta gives errors as it's not explicitly typed. Generating (and exporting) the type annotations would be nice.

https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#isolated-declarations

Your Example Website or App

https://github.com/SimenB/router-isolated-declarations

Steps to Reproduce the Bug or Issue

Run the TypeScript compiler in the linked reproduction

Expected behavior

No type errors.

Screenshots or Videos

No response

Platform

N/A

Additional context

No response

SeanCassiere commented 1 week ago

@chorobin @schiller-manuel is isolatedDeclarations a flag we hope working with TSR?

Looking at the article linked, the solution to this seems to be the use of explicit types (and return types).

isolatedDeclarations should be adopted on a case-by-case basis.

They do also mention this though 👆🏼.

Should we be looking at this now? or should we wait for Typescript 5.5 to be released and then added into our type-matrix in CI?

SimenB commented 1 week ago

Note that this issue is specifically about the code generated by @tanstack/router-generator output into the user's code base, not necessarily the router's own code base.

(in theory, this might improve type checking performance as well as noted in https://typescript-eslint.io/rules/explicit-module-boundary-types/, but my point was mainly to help/not block users from using the flag)