Add tsgo (TypeScript 7 native preview) type-check to CI - #765
Conversation
✅ Deploy Preview for reselect-docs canceled.
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
isn't typescript 7 in stable release now, so we don't need the preview package? it should be enough just to add 7 to the matrix we also follow the DefinitelyTyped window so you can remove anything older than 5.6 |
59c51fd to
276a0c5
Compare
|
Good catch, TS 7 is stable now so the preview package was overkill. Dropped the native-preview dep and the separate tsgo job — just added 7.0 (and 6.0) to the type matrix so it runs with the normal tsc like everything else. Also trimmed the versions below 5.6 to match the DefinitelyTyped window. Checked locally that the types pass on both 6.0.3 and 7.0.2. |
|
i'll merge #764 once CI passes on that, so this can then be rebased and we can get a better CI picture |
276a0c5 to
3dcb3e7
Compare
Summary
TypeScript 7 ships as a native (Go) compiler, distributed today as
@typescript/native-previewwith atsgobinary. This PR adds a CI job that type-checks Reselect's type tests withtsgo, and makes the small set of changes needed for the wholetypescript_testsuite to pass cleanly under bothtscandtsgo. Everything stays green on the existingtscmatrix (5.0 through 5.8), so the day TS 7 becomes the compiler we build with, there's nothing left to fix.Why
tsgois close enough that it's worth running in CI today rather than discovering a wall of incompatibilities later. Pointing it at a heavily overload-driven library like Reselect turned out to be a good stress test, and it surfaced a few genuine forward-compatibility items in our config plus one interesting difference in how errors are reported.What's in here
Config that TypeScript 7 no longer accepts.
tsgorejects a few options that were removed in TS 7, sotsconfig.jsonneeded updating:moduleResolution: "Node"(node10) becomes"bundler", the now-removedbaseUrlis dropped, and thepathsentries get the leading./that TS 7 requires. These are no-ops fortsc5.x and for the Vitest type tests, which still pass unchanged.Type-test lib and globals. The
typescript_testproject pinnedlibto justES2021.WeakRef. Classictscpulls the rest of the standard library in through that file's reference chain, buttsgodoesn't, so it's nowES2021(a superset — same APIs). It also picks uptypes: ["node"]becausetsgodoesn't auto-include@types/nodeglobals the waytscdoes, and a couple ofsrcfiles touchconsole/process.The negative type tests. This is the bulk of the diff, and it's mostly deletions. Our
@ts-expect-errorassertions for the "this call should be a type error" cases spanned multi-line calls, with the directive sitting on the linetschappens to report the overload error on.tsgoreports the same errors — it just pins them to the specific offending argument instead — which left those directives looking unused. Since@ts-expect-erroris tied to the exact next line, there's no multi-line arrangement that satisfies both compilers, so each of these calls is now collapsed onto a single line with one leading@ts-expect-error. The assertions stay exactly as strict; they simply stop caring about where the squiggle is drawn. Positive tests and everything else are untouched.One relaxed assertion.
createStructuredSelector(...).dependenciesis currently inferred in a different tuple order bytsgothan bytsc. That single spot swaps its exact-tupleexpectExactTypefor a membership check on the same three signatures, with a comment explaining why. The runtime ordering is still covered by the regular unit tests.The wiring.
@typescript/native-previewis added as a dev dependency, there's atype-check:tsgoscript (tsgo --noEmit -p typescript_test/tsconfig.json, mirroringtest:typescript), and a newtest-types-tsgojob in the CI workflow that runs it.Notes
The dev build is pinned rather than tracking
latestso the job doesn't turn red on an unrelated upstream change. When TS 7 stabilises this can move to a real release and, if we ever want it, into the version matrix alongside thetscruns.