fix(compiler): adopt tsconfig paths/baseUrl for the ts7 checker - #197
Open
techfreaque wants to merge 1 commit into
Open
fix(compiler): adopt tsconfig paths/baseUrl for the ts7 checker#197techfreaque wants to merge 1 commit into
techfreaque wants to merge 1 commit into
Conversation
Contributor
|
@mabr-pcvisit is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
adoptProjectConfig7() only copies ADOPTED_OPTIONS (a small strictness-flag
allowlist) from the project's real tsconfig.json into the options handed to
the spawned tsgo (TypeScript 7 native) process. `paths` and `baseUrl` were
silently dropped, so any project using tsconfig path aliases (e.g.
`"@/*": ["./src/*"]`) hit `error SC0001: Cannot find module '@/foo'` even
though tsgo's checker fully supports `paths`/`baseUrl` natively.
Adopt `paths`, resolving relative targets to absolute paths against the
real config's directory (or its `baseUrl`, when set) rather than passing
them through unresolved: the synthesized virtual tsconfig that carries
these options to tsgo (ts7/program.ts) is written beside the entry file,
not beside the real tsconfig.json, so relative targets would otherwise
resolve against the wrong base. `baseUrl` itself is not forwarded — tsgo
rejects it outright as a removed option ("Option 'baseUrl' has been
removed... Use '\"paths\": {\"*\": [\"./*\"]}' instead."); the absolute
`paths` targets already make it unnecessary.
Adds a regression test asserting SC0001 no longer fires for an aliased
import once a tsconfig `paths` entry is in play.
techfreaque
force-pushed
the
fix-ts7-paths-baseurl
branch
from
August 22, 2026 09:29
fbbe368 to
357d99a
Compare
techfreaque
added a commit
to techfreaque/scriptc
that referenced
this pull request
Aug 22, 2026
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
Any project whose tsconfig uses
pathsaliases (e.g."@/*": ["./src/*"]) fails type-checking with:even though the underlying checker (tsgo, TypeScript 7 native) fully supports
paths/baseUrlnatively.Root cause
Type-checking is driven by a spawned
tsgoprocess against a synthesized in-memory virtual tsconfig, built inpackages/compiler/src/frontend/program.ts'sadoptProjectConfig7(). That function only copies a small strictness-flag allowlist (ADOPTED_OPTIONS) from the project's realtsconfig.jsoninto the options handed to tsgo —pathsandbaseUrlare silently dropped, so tsgo never learns about the aliases and fails to resolve them.Fix
adoptProjectConfig7()now also adoptspaths, resolving relative targets to absolute paths against the real config's directory (or itsbaseUrl, when set), since the virtual tsconfig fed to tsgo is written beside the entry file rather than beside the realtsconfig.json— passing relative targets through unresolved would make tsgo resolve them against the wrong base.baseUrlitself is intentionally not forwarded: tsgo rejects it outright as a removed option ("Option 'baseUrl' has been removed... Use"paths": {"*": ["./*"]}instead."). Resolvingpathstargets to absolute paths up front makes forwardingbaseUrlunnecessary.Verification
packages/compiler:node node_modules/typescript5/bin/tsc -p tsconfig.json— 0 errors.packages/compiler/test/ts7/program.test.tscoveringadoptProjectConfig7vialoadProgram/checkPreflight: builds a temp project with apathsalias (@/*→./src/*) and an aliased import, and assertsSC0001no longer appears in the preflight diagnostics. Confirmed the test reproduces the original bug (fails with the exactSC0001message above) against the unpatched code, and passes with the fix.packages/compiler/test/ts7suite; no new failures introduced (two pre-existing Windows path-separator test failures on this platform predate this change, verified against a clean checkout).