Skip to content

Add tests for uncovered module resolution and specifier paths - #65656

Open
YT (magurotuna) wants to merge 1 commit into
microsoft:mainfrom
magurotuna:tsrs-regression-tests
Open

YT (magurotuna) wants to merge 1 commit into
microsoft:mainfrom
magurotuna:tsrs-regression-tests

Conversation

@magurotuna

@magurotuna YT (magurotuna) commented Nov 24, 2026 •

Copy link
Copy Markdown

Fixes #65657

This PR adds compiler tests for three code paths that no existing test covers. It does not change the compiler.

I found them in tsrs, a Rust port of tsc/ that runs these tests as its conformance suite. Each case was a tsrs bug that no test caught:

…lative type reference names

These compiler tests cover three code paths that no existing test covered:

- getPackageId with a "types" field that points outside the package directory
- the nodeModulesPrefix check in tryGetModuleNameAsNodeModule for a file directly in node_modules
- a relative type reference name that is resolved from a type root
Copilot AI balanced review requested due to automatic review settings November 24, 2026 16:27
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 24, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 24, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

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

There are no active review issues for this test-only addition of module-resolution and declaration-specifier regression coverage.

No open issues 🎉

What changed in this PR

This test-only PR adds regression coverage for three module-resolution and declaration-specifier edge cases identified through the tsrs conformance suite. It adds expected baselines without changing compiler code.

Changes:

  • Verify that packages whose types entry points outside their directory remain distinct.
  • Cover declaration emit for a type defined directly in /node_modules/index.d.ts.
  • Cover relative type-reference resolution from a configured type root, including normalized resolution traces.
File Description
tsc/​testdata/​tests/​cases/​compiler/​typeReferenceDirectiveRelativeNameFromTypeRoot.ts Tests relative type references from a type root.
tsc/​testdata/​tests/​cases/​compiler/​duplicatePackage_typesOutsidePackageDirectory.ts Tests package identity with an external types target.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitNodeModulesIndexFile.ts Tests declaration specifiers for a direct node_modules file.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveRelativeNameFromTypeRoot.types Records resolved global and exported types.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveRelativeNameFromTypeRoot.trace.json Records normalized primary-lookup resolution.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveRelativeNameFromTypeRoot.symbols Records resolved symbol bindings.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveRelativeNameFromTypeRoot.js Records JavaScript output.
tsc/​testdata/​baselines/​reference/​compiler/​duplicatePackage_typesOutsidePackageDirectory.types Records distinct package class types.
tsc/​testdata/​baselines/​reference/​compiler/​duplicatePackage_typesOutsidePackageDirectory.symbols Records separate class symbol bindings.
tsc/​testdata/​baselines/​reference/​compiler/​duplicatePackage_typesOutsidePackageDirectory.js Records JavaScript output.
tsc/​testdata/​baselines/​reference/​compiler/​duplicatePackage_typesOutsidePackageDirectory.errors.txt Records the expected TS2322 assignment error.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitNodeModulesIndexFile.types Records inferred types and import specifiers.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitNodeModulesIndexFile.symbols Records interface and re-export bindings.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitNodeModulesIndexFile.js Records JavaScript and relative declaration output.

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good regression test addition, but the three cases should be checked against the actual compiler behavior rather than relying only on the Rust port's findings. In particular, verify that the package ID test catches the missing RelativeTo check, declaration emit correctly handles files directly under node_modules, and relative type reference names are resolved correctly from type roots. Recommendation: Approve once all three tests are confirmed to fail without the corresponding fixes and pass against the current TypeScript implementation.

@typescript-automation typescript-automation Bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 25, 2026

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 Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

No tests cover some module resolution and module specifier cases

3 participants