Repository navigation
Ignore source files / module declarations in couldContainTypeVariables - #65481
Open
Jake Bailey (jakebailey) wants to merge 2 commits into
Open
Jake Bailey (jakebailey) wants to merge 2 commits into
Jake Bailey (jakebailey) wants to merge 2 commits into
Conversation
The object type wrapping a module for a synthetic default import has
the module's declarations, so that types are ordered the same way
wherever it is compared. Having declarations made it an anonymous type
that could reference type parameters, so inference explored its
members. For import("cloudflare:workers").then(mod => mod), inferring
from the callback erased the type parameter of a generic function the
module exports, and instantiating its return type with any never
ended, reporting TS5115. A module is never within the scope of a type
parameter, so the wrapper is again known not to contain any.
Fixes 65445
Jake Bailey (jakebailey)
requested review from
Anders Hejlsberg (ahejlsberg)
and
a balanced review from Copilot
November 13, 2026 05:37
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the dynamic-import inference fix.
No open issues 🎉
What changed in this PR
Addresses #65445, a TS5115 regression during dynamic-import callback inference, by preventing the native compiler from exploring synthetic module wrappers that cannot reference type parameters.
Changes:
- Exclude wrappers backed by source-file or module declarations from
couldContainTypeVariables. - Add a regression test combining dynamic import, callback inference, and recursive conditional types.
- Add expected type and symbol baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/syntheticDefaultImportTypeInference.ts |
Adds the focused dynamic-import inference regression test. |
tsc/testdata/baselines/reference/compiler/syntheticDefaultImportTypeInference.types |
Records expected inferred types, including Promise<number>. |
tsc/testdata/baselines/reference/compiler/syntheticDefaultImportTypeInference.symbols |
Records expected symbol bindings for the regression test. |
tsc/internal/checker/checker.go |
Identifies module wrappers and excludes them from type-variable traversal. |
Review effort: Balanced
This branch has not been deployed
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 #65445
This traces back to microsoft/typescript-go#4687. That PR gave a synthetic module wrapper symbol a declaration so it could be sorted, but then that made
couldContainTypeVariableswalk into it when it shouldn't. Strada didn't give that symbol a declaration so it didn't either.Fix it by skipping decls that are source files / module declarations.