Skip to content

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

Merged
Gabriela Araujo Britto (gabritto) merged 2 commits into
microsoft:mainfrom
Andarist:preserve-script-module-errors
Oct 26, 2026
Merged

Gabriela Araujo Britto (gabritto) merged 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

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Oct 20, 2026
Merged via the queue into microsoft:main with commit 49e6983 Oct 26, 2026
29 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Oct 26, 2026
Harsh Mandan (harshmandan) added a commit to harshmandan/svelte-check-native that referenced this pull request Oct 27, 2026
First nightly with the TS2306 ordering restored (built from 49e69830, the
merge of microsoft/TypeScript#64884 for #64882): an import that resolves
to a non-module file reports TS2306 again instead of falling back to a
pattern ambient module. Fixtures 502 and 503 pass, and the full suite is
green (1293 passed, 0 failed).
Harsh Mandan (harshmandan) added a commit to harshmandan/svelte-check-native that referenced this pull request Oct 27, 2026
First nightly with the TS2306 ordering restored (built from 49e69830, the
merge of microsoft/TypeScript#64884 for #64882): an import that resolves
to a non-module file reports TS2306 again instead of falling back to a
pattern ambient module. Fixtures 502 and 503 pass, and the full suite is
green (1293 passed, 0 failed).
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: Done

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

5 participants