Type check with the TypeScript 7 native compiler - #338
Open
pysnooLab wants to merge 3 commits into
Open
Conversation
TypeScript 7 removes the baseUrl option, so paths now resolve relative to the tsconfig file. tsconfig-paths 4.2, used by the Storybook docgen, reports the same absoluteBaseUrl without it, so the tooling is unaffected. getList and getOne were redeclared non generic in the Supabase data provider, while several call sites pass a type argument such as getOne<Sale>. TypeScript 5.8 accepted it, TypeScript 7 rejects it with TS2558. Making both methods generic fixes the call sites at the root rather than stripping their type arguments. The IntersectionObserver stub in the notes test gains scrollMargin, which the lib.dom shipped with TypeScript 7 declares as required. Both compilers type check clean after this change, so this stays valid on TypeScript 5.8.
typescript@7 is the Go compiler and no longer ships the JS API that typescript-eslint needs. Upstream closed the TypeScript 7 support request as not planned until that API lands in 7.1, and points at the side by side setup documented in the 7.0 announcement. So tsc now comes from typescript@7 through the @typescript/native alias, while the typescript entry resolves to @typescript/typescript6 so eslint keeps a supported peer. The two binaries do not collide, tsc for 7 and tsc6 for 6, so no script needed a change. Measured on this project, five runs each: type checking drops from a 4.66s median to 1.10s.
The lockfile pinned typescript-eslint 8.41.0, whose peer range is typescript >=4.8.4 <6.0.0 and therefore excludes the 6.0.2 compatibility package. ESLint itself runs fine on that pair, but npm ci refuses the resolution and the CI could not install at all. 8.58.0 is the first release widening the range to <6.1.0, so it becomes the floor. npm ci --dry-run now resolves clean.
erwanMarmelab
requested changes
Aug 25, 2026
| "files": [], | ||
| "references": [ | ||
| { "path": "./tsconfig.app.json" }, | ||
| { "path": "./tsconfig.node.json" } |
Contributor
There was a problem hiding this comment.
tsconfig.node.json no longer compiles under TS 7, so vite.config.ts is untypecheckable.
| "test:unit:functions": "vitest --config vitest.config.ts --project functions", | ||
| "dev": "vite --force", | ||
| "dev:demo": "vite --config vite.demo.config --force", | ||
| "build": "tsc && vite build", |
Contributor
There was a problem hiding this comment.
tsc type-checks nothing (files: []). We need to find another way (like npm run typecheck. But without the npm to let users use their own package manager)
Contributor
There was a problem hiding this comment.
I still can find typescript6 in the package-lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TypeScript 7 (GA on 2026-07-08) is the Go compiler and is around 10x faster, but it cannot simply replace
typescript@5.8: it no longer ships the JS API thattypescript-eslintneeds. Upstream closed the TypeScript 7 support request asnot planneduntil that API lands in 7.1, so a plain bump breaks ESLint on every.ts/.tsx.The codebase was not TS 7 ready either:
baseUrlhas been removed from the compiler options, andgetList/getOnewere redeclared non generic in the Supabase data provider while several call sites pass a type argument (getOne<Sale>). TS 5.8 accepted that, TS 7 rejects it with TS2558.Solution
The side by side setup documented in the TypeScript 7.0 announcement:
tsccomes fromtypescript@7through the@typescript/nativealiastypescriptentry resolves to@typescript/typescript6, so ESLint keeps a supported peertypescript-eslintfloor raised to^8.58.0, the first release whose peer range widens totypescript <6.1.0. Below that,npm cirefuses the resolution outright.The two binaries do not collide (
tscfor 7,tsc6for 6), so no script and no CI job changed. Removing the alias is all it takes oncetypescript-eslintsupports 7.1.Plus the compatibility fixes, all of which stay valid on TS 5.8:
baseUrldropped from both tsconfigs (pathsnow resolve relative to the tsconfig file, andtsconfig-paths4.2 used by the Storybook docgen reports the sameabsoluteBaseUrlwithout it)getList/getOnemade generic in the Supabase and FakeRest providers, which fixes the call sites at the root instead of stripping their type argumentsscrollMarginadded to theIntersectionObserverstub in the notes test, now required by the lib.dom shipped with TS 7Measured here, 5 runs each: type checking drops from a 4.66s median to 1.10s (4.2x). The build is unchanged,
vite builddoes not go throughtsc.Two known limits, both dormant:
tsconfig.node.json(thevite.config.tsproject) fails under TS 7 because the program pulls innode_modules/@swc/html/index.ts, a raw.tsshipped by a third party, incompatible withverbatimModuleSyntax. No script or CI job targets that project today.TypeScriptTeam.native-previewextension (VS Code >= 1.126) to get the native language server, it is not built into VS Code yet as of 1.131.How to test