Skip to content

removing skipLibCheck causes type errors (even on the starter template created by create-tsrouter) #4114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
FoHoOV opened this issue May 8, 2025 · 1 comment
Labels
types Changes to the typescript types

Comments

@FoHoOV
Copy link

FoHoOV commented May 8, 2025

Which project does this relate to?

Router

Describe the bug

The title is self explanatory, removing skipLibCheck from tsconfig causes type errors from the tanstack/router-core pacakge. I can't have skipLibCheck because I want my d.ts files to be checked.

node_modules/.pnpm/@tanstack+router-core@1.119.0/node_modules/@tanstack/router-core/dist/esm/route.d.ts:370:22 - error TS2420: Class 'BaseRoute<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, ... 5 more ..., TFileRouteTypes>' incorrectly implements interface 'Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, ... 5 more ..., TFileRouteTypes>'.
  Type 'BaseRoute<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, ... 5 more ..., TFileRouteTypes>' is missing the following properties from type 'Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, ... 5 more ..., TFileRouteTypes>': useMatch, useRouteContext, useSearch, useParams, and 4 more.

370 export declare class BaseRoute<in out TParentRoute extends AnyRoute = AnyRoute, in out TPath extends string = '/', in out TFullPath extends string = ResolveFullPath<TParentRoute, TPath>, in out TCustomId extends string = string, in out TId extends string = ResolveId<TParentRoute, TCustomId, TPath>, in out TSearchValidator = undefined, in out TParams = ResolveParams<TPath>, in out TRouterContext = AnyContext, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record<string, any> = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> implements Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, TFileRouteTypes> {
                         ~~~~~~~~~

node_modules/.pnpm/@tanstack+router-core@1.119.0/node_modules/@tanstack/router-core/dist/esm/route.d.ts:403:23 - error TS2344: Type 'this' does not satisfy the constraint 'AnyRoute'.
  Type 'BaseRoute<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchValidator, TParams, TRouterContext, ... 5 more ..., TFileRouteTypes>' is missing the following properties from type 'Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any>': useMatch, useRouteContext, useSearch, useParams, and 4 more.

403     lazy: RouteLazyFn<this>;
                          ~~~~

Your Example Website or App

Steps to Reproduce the Bug or Issue

  1. npx create-tsrouter-app@latest my-app --template file-router
  2. remove skipLibCheck from tsconfig
  3. run tsc --build --noEmit

Expected behavior

I expect no type errors to occure.

Screenshots or Videos

No response

Platform

  • OS: [Linux]
  • Browser: not relevant
  • Version: [1.120.2]

Additional context

No response

@SeanCassiere
Copy link
Member

@chorobin is there anything that can really be done for this in @tanstack/router-core?

As far as I understand, the recommended way for pretty much any user typescript project is to turn on skipLibCheck since it has positive dev experience performance implications without having to validate the .d.ts files in all your packages (plus its dependencies).

The default templates for pretty much every major framework (like Vite, Astro, Next, React Router) have it turned on for a reason.

@SeanCassiere SeanCassiere added the types Changes to the typescript types label May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types Changes to the typescript types
Projects
None yet
Development

No branches or pull requests

2 participants