Skip to content

Preserve non-module errors for imports without attributes - #64884

Open
Mateusz Burzyński (Andarist) wants to merge 2 commits into
microsoft:mainfrom
Andarist:preserve-script-module-errors
Open

Mateusz Burzyński (Andarist) wants to merge 2 commits into
microsoft:mainfrom
Andarist:preserve-script-module-errors

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes #64882

fixes a, what seems to be an unintended, behavioral change from #63931 , given this statement from that PR:

If there's no import attributes type, the algorithm remains unchanged, and pattern ambient modules are only used for resolution if regular resolution fails.

cc Gabriela Araujo Britto (@gabritto)

Copilot AI balanced review requested due to automatic review settings October 20, 2026 13:13
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 20, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrow guard restores the intended resolution order, with matching regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Restores TS2306 diagnostics when imports without attributes resolve to non-module files, addressing #64882 while preserving attribute-based ambient module resolution.

Changes:

  • Guards pattern ambient fallback for resolved scripts.
  • Adds regression tests and diagnostic baselines covering resolution paths, empty attributes, and empty modules.
File Description
tsc/​testdata/​tests/​cases/​compiler/​patternAmbientModuleResolvedScriptWithoutPaths.ts Tests resolution without path mappings.
tsc/​testdata/​tests/​cases/​compiler/​patternAmbientModuleResolvedScript.ts Tests resolved scripts and attribute precedence.
tsc/​testdata/​tests/​cases/​compiler/​patternAmbientModuleResolvedEmptyModule.ts Tests empty-module resolution precedence.
tsc/​testdata/​baselines/​reference/​compiler/​patternAmbientModuleResolvedScriptWithoutPaths.errors.txt Records diagnostics without path mappings.
tsc/​testdata/​baselines/​reference/​compiler/​patternAmbientModuleResolvedScript.errors.txt Records restored non-module errors.
tsc/​testdata/​baselines/​reference/​compiler/​patternAmbientModuleResolvedEmptyModule.errors.txt Records empty-module diagnostics.
tsc/​internal/​checker/​checker.go Limits resolved-script fallback to nonempty attributes.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Needs merge

Development

Successfully merging this pull request may close these issues.

7.1 regression: import resolving to a non-module file falls back to a pattern ambient module instead of TS2306

3 participants