fix: resolve tsconfig path aliases containing a colon#780
Merged
privatenumber merged 4 commits intoMay 17, 2026
Merged
Conversation
6 tasks
Owner
|
This issue is now resolved in v4.22.1. If you're able to, your sponsorship would be very much appreciated. |
This was referenced May 17, 2026
This was referenced May 24, 2026
1 task
This was referenced May 28, 2026
5 tasks
This was referenced Jun 5, 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.
Fixes #730
tsconfig.pathsaliases that contain:in both async and sync ESM resolution.pathsapplies to non-relative module names, and:is ordinary pattern text.data:,file:,node:, andscheme://instead of remapping them throughpaths.Context
TypeScript supports colon-containing path aliases because it only excludes relative module names from
pathsmatching.In TypeScript's resolver,
pathsis attempted whenpaths && !pathIsRelative(moduleName).pathIsRelative()only matches./and../style specifiers, so aliases likens:utils.mjsanda:b/bare eligible non-relative module names. Pattern parsing treats only*specially, which means:is matched as literal text.Relevant TypeScript source checked against
microsoft/TypeScript@f350b52331494b68c90ab02e2b6d0828d2a22a74:tryLoadModuleUsingPathsIfEligiblegatespathson!pathIsRelative(moduleName).pathIsRelativeonly detects./..relative paths.tryParsePatternonly gives special meaning to*.A local
ts.resolveModuleName()probe confirmed the same behavior:a:b/bmatchesa:b/*and resolves to/project/b.ts.ns:utils.mjsmatchesns:*and resolves through TS extension substitution to/project/src/utils.mts.get-tsconfig.resolvePathAlias()also resolves these aliases, so the bug is not thatget-tsconfigrejects:. The issue is tsx filtering the specifier before callingresolvePathAlias().Problem
The ESM hook used
requestAcceptsQuery(specifier)as the gate fortsconfig.pathsresolution.That helper treats any
:as URL-like, sons:utils.mjsskipped path alias resolution and was passed directly to Node's ESM loader. Node then rejected it as an unsupported URL scheme instead of letting the configured TypeScript path alias map it to a file.At the same time, blindly removing the gate would be wrong for a runtime loader: TypeScript can type-resolve
data:*throughpaths, but tsx must still execute realdata:imports as data URLs.Changes
isTsconfigPathAliasSpecifier().ns:utils.mjsto reachresolvePathAlias().pathsresolution:data:,file:,node:, and schemes with://.data:URL imports.Verification
fnm exec --using 24.15.0 pnpm type-checkfnm exec --using 24.15.0 pnpm lintCI=true fnm exec --using 24.15.0 pnpm test