chore: upgrade to TypeScript 7 - #99
Draft
ibgreen wants to merge 1 commit into
Draft
Conversation
ibgreen
force-pushed
the
codex/upgrade-typescript-7
branch
from
July 29, 2026 16:45
35f08bc to
572792a
Compare
ibgreen
force-pushed
the
codex/upgrade-typescript-7
branch
from
July 29, 2026 18:52
572792a to
71c1fc0
Compare
Interesting approach. I like that it doesn't burden us with maintaining a complex parser. This does feel like something the TS community would ideally solve for us in the long term.. we couldn't be the only project trying to emit TS, JS, d.ts, ESM, and CommonJS.. right? |
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.
Summary
@typescript/nativeocular-buildwith a small explicit build pipelineWhy the build pipeline needs a workaround
The previous build depended on
@vis.gl/ts-pluginsthroughts-patch. Its append-extension transformer ran inside the JavaScript TypeScript compiler and changed relative module specifiers in both JavaScript and declaration output.TypeScript 7 uses the native compiler. That compiler cannot be patched by
ts-patchand does not load the JavaScript custom transformers used by@vis.gl/ts-plugins, so the oldocular-buildpath cannot perform this repository's required emit transformation.An earlier version of this PR worked around that limitation by spelling emitted
.jsextensions in the.tssource. That couples source authoring to one output format and creates unnecessary risk for tests, bundlers, and future build targets. This revision removes all of that source churn:modules/*/srcis byte-for-byte unchanged frommaster, and TypeScript usesmoduleResolution: "bundler"to continue resolving the existing extensionless imports.Post-emission solution
The new build has three explicit stages:
.jsand.d.tsfiles.The postprocessor deliberately does not use textual search-and-replace. It uses the retained TypeScript 6 compatibility package only as a JavaScript parser, walks module-specifier syntax nodes (static imports/exports, dynamic imports,
require, import types, and import-equals), and ignores comments, ordinary strings, package imports, and specifiers that already have extensions.For every extensionless relative specifier, it checks the emitted filesystem before changing anything:
./target.js./target/index.jsThe same transformation is applied to declaration files. When a suffix is inserted, the corresponding JavaScript or declaration source-map mappings are shifted by the exact inserted column count, preserving mapping accuracy. TypeScript 6 is therefore a narrow parser/tooling compatibility dependency; TypeScript 7 remains the compiler used for checking and emission.
This keeps the workaround isolated at the boundary where the runtime requirement actually exists: generated package artifacts, not authored TypeScript.
Validation
yarn install --immutableyarn build.js/.d.tsfiles contain no extensionless relative module specifiersyarn lintyarn test node: 2,719 passingyarn test ci: full browser suite passingmodules/*/srchas no diff frommasterThe rewriter also has focused coverage for JavaScript output, declaration output, source-map adjustment, Node ESM loading, and failure on an unresolved emitted specifier.