Skip to content

Add tests for path edge cases in resolution, emit, and builds - #65667

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

YT (magurotuna) wants to merge 2 commits into
microsoft:mainfrom
magurotuna:tsrs-regression-tests-2

Conversation

@magurotuna

Copy link
Copy Markdown

Fixes #65657

Follow-up to #65656.

This PR adds 15 compiler tests and 10 Go tests. It changes only tests and one test helper. Each test would have caught a tsrs bug that the existing tests missed. The test also fails if you add the same bug to the Go code.

  • Module and type reference resolution: names that end with /, drive roots (C:), type roots under ^/ URIs, imports targets that are directories, and package self-names with outDir and rootDir (tsrs#1007, tsrs#1008, tsrs#1009, tsrs#1049, tsrs#1079).
  • Triple-slash references: a drive root, and a reference to the file itself without an extension (tsrs#1023, tsrs#1057).
  • Declaration emit: exports targets that end with /, and an /index specifier next to a file with the same name (tsrs#1024, tsrs#1077).
  • Source maps and output paths: mapRoot with .. and ^, and the build info name of a c:.json config (tsrs#1040, tsrs#1063).
  • Config files: absolute include paths with .., rootDir with case-sensitive names, and files entries that are rooted or have a .d.ts sibling (tsrs#1021, tsrs#1052, tsrs#1053, tsrs#1064).
  • tsc and tsc -b: -p with a subfolder, a build with no inputs, and build info tuples of the wrong length (tsrs#1022, tsrs#1025, tsrs#1050). The build info edits use a new helper, replaceFileTextNoMiss, that panics when the text to replace is missing.
  • Language service and API: rename to a name that is not normalized, the file:///d%3A URI, and API file names that end with / (tsrs#1039, tsrs#1061, tsrs#1065).

One test differs from TypeScript 6: selfReferencingFileWithoutExtension expects TS1006 for /// <reference path="a" /> in a.ts. TypeScript 6 reports TS1006 only for path="a.ts".

Each test passes on main and fails when the matching tsrs bug is added
to the Go code.
…the API

Each test passes on main and fails when the matching tsrs bug is added
to the Go code.

This commit also updates compiler tests from the first commit after a
review: decoy files for the trailing slash guards, a different base
directory in two tests, and comment fixes.
Copilot AI balanced review requested due to automatic review settings November 25, 2026 15:19
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 25, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Nov 25, 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

No active review issues remain for the path-handling regression coverage.

No open issues 🎉

2 files not reviewed
  • tsc/testdata/baselines/reference/compiler/mapRootRelativeCaret.js: Generated file
  • tsc/testdata/baselines/reference/compiler/mapRootUrlWithDotDotSegment.js: Generated file
What changed in this PR

Adds regression coverage for path handling across the TypeScript compiler, build pipeline, language service, and API. This follows #65656 and addresses #65657 without changing production behavior.

Changes:

  • Adds compiler tests for resolution, references, declaration emit, source maps, and config path edge cases.
  • Extends Go tests for URI normalization, rename destinations, output paths, and build recovery.
  • Adds expected baselines and a test helper that rejects text replacements when the target text is missing.
File Description
tsc/​testdata/​tests/​cases/​compiler/​typeReferenceDirectiveTrailingSlashRelativeName.ts Tests directory-only relative type references.
tsc/​testdata/​tests/​cases/​compiler/​typeReferenceDirectiveDriveRoot.ts Tests drive-root type references.
tsc/​testdata/​tests/​cases/​compiler/​tsconfigIncludeAbsolutePathWithDotDot.ts Tests absolute include-path normalization.
tsc/​testdata/​tests/​cases/​compiler/​tripleSlashReferenceDriveRoot.ts Tests drive-root file references.
tsc/​testdata/​tests/​cases/​compiler/​selfReferencingFileWithoutExtension.ts Tests extensionless self-reference detection.
tsc/​testdata/​tests/​cases/​compiler/​rootDirWithCaseSensitiveFileNames.ts Tests case-sensitive root-directory boundaries.
tsc/​testdata/​tests/​cases/​compiler/​packageJsonImportsDirectoryOnlyTarget.ts Tests slash-terminated package imports targets.
tsc/​testdata/​tests/​cases/​compiler/​nodeNextPackageSelfNameWithOutDirRootDirCaretDirectory.ts Tests self-name mapping through caret directories.
tsc/​testdata/​tests/​cases/​compiler/​nodeNextPackageSelfNameWithOutDirRootDirAtRoot.ts Tests self-name mapping at filesystem root.
tsc/​testdata/​tests/​cases/​compiler/​moduleResolutionAsTypeReferenceDirectiveTrailingSlash.ts Tests directory-only type-root fallback.
tsc/​testdata/​tests/​cases/​compiler/​mapRootUrlWithDotDotSegment.ts Tests source-map URL normalization.
tsc/​testdata/​tests/​cases/​compiler/​mapRootRelativeCaret.ts Tests relative caret map directories.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitIndexDirectoryOutsideImportingDirectory.ts Tests preservation of unambiguous /index specifiers.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitExportsTargetTrailingSlash.ts Tests directory-only exports during declaration emit.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitExportsPatternTargetTrailingSlash.ts Tests directory-only exports patterns during declaration emit.
tsc/​testdata/​baselines/​reference/​tsc/​incremental/​tsbuildinfo-has-tuple-of-wrong-length.js Records recovery from malformed build-info tuples.
tsc/​testdata/​baselines/​reference/​tsc/​commandLine/​rooted-file-names-in-tsconfig-do-not-exist.js Records missing rooted-file diagnostics.
tsc/​testdata/​baselines/​reference/​tsc/​commandLine/​Parse--p-with-path-to-subfolder-that-has-only-declaration-files-and-outDir.js Records subfolder compilation and build outputs.
tsc/​testdata/​baselines/​reference/​tsbuild/​configFileErrors/​reports-no-inputs-found.js Records empty-input build diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveTrailingSlashRelativeName.types Records directory-resolved global types.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveTrailingSlashRelativeName.trace.json Records directory-only reference lookup.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveTrailingSlashRelativeName.symbols Records directory-resolved symbols.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveTrailingSlashRelativeName.js Records reference fixture emit.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveTrailingSlashRelativeName.errors.txt Records exclusion of sibling-file globals.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveDriveRoot.types Records drive-root reference type output.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveDriveRoot.trace.json Records unresolved drive-root lookup.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveDriveRoot.symbols Records drive-root reference symbol output.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveDriveRoot.js Records drive-root reference emit.
tsc/​testdata/​baselines/​reference/​compiler/​typeReferenceDirectiveDriveRoot.errors.txt Records missing drive-root type definitions.
tsc/​testdata/​baselines/​reference/​compiler/​tsconfigIncludeAbsolutePathWithDotDot.types Records types from both included directories.
tsc/​testdata/​baselines/​reference/​compiler/​tsconfigIncludeAbsolutePathWithDotDot.symbols Records symbols from both included directories.
tsc/​testdata/​baselines/​reference/​compiler/​tsconfigIncludeAbsolutePathWithDotDot.errors.txt Records diagnostics proving both files are included.
tsc/​testdata/​baselines/​reference/​compiler/​tripleSlashReferenceDriveRoot.types Records drive-root file-reference type output.
tsc/​testdata/​baselines/​reference/​compiler/​tripleSlashReferenceDriveRoot.symbols Records drive-root file-reference symbol output.
tsc/​testdata/​baselines/​reference/​compiler/​tripleSlashReferenceDriveRoot.js Records drive-root file-reference emit.
tsc/​testdata/​baselines/​reference/​compiler/​tripleSlashReferenceDriveRoot.errors.txt Records unresolved drive-root file diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​selfReferencingFileWithoutExtension.types Records self-referencing file types.
tsc/​testdata/​baselines/​reference/​compiler/​selfReferencingFileWithoutExtension.symbols Records self-referencing file symbols.
tsc/​testdata/​baselines/​reference/​compiler/​selfReferencingFileWithoutExtension.js Records self-referencing file emit.
tsc/​testdata/​baselines/​reference/​compiler/​selfReferencingFileWithoutExtension.errors.txt Records extensionless self-reference diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​rootDirWithCaseSensitiveFileNames.types Records case-distinct source types.
tsc/​testdata/​baselines/​reference/​compiler/​rootDirWithCaseSensitiveFileNames.symbols Records case-distinct source symbols.
tsc/​testdata/​baselines/​reference/​compiler/​rootDirWithCaseSensitiveFileNames.js Records case-sensitive root-directory emit.
tsc/​testdata/​baselines/​reference/​compiler/​rootDirWithCaseSensitiveFileNames.errors.txt Records out-of-root diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​packageJsonImportsDirectoryOnlyTarget.types Records unresolved imports target types.
tsc/​testdata/​baselines/​reference/​compiler/​packageJsonImportsDirectoryOnlyTarget.trace.json Records directory-only imports lookup.
tsc/​testdata/​baselines/​reference/​compiler/​packageJsonImportsDirectoryOnlyTarget.symbols Records unresolved import symbols.
tsc/​testdata/​baselines/​reference/​compiler/​packageJsonImportsDirectoryOnlyTarget.errors.txt Records directory-target resolution failure.
tsc/​testdata/​baselines/​reference/​compiler/​nodeNextPackageSelfNameWithOutDirRootDirCaretDirectory.types Records types resolved through a caret directory.
tsc/​testdata/​baselines/​reference/​compiler/​nodeNextPackageSelfNameWithOutDirRootDirCaretDirectory.symbols Records caret-directory self-name symbols.
tsc/​testdata/​baselines/​reference/​compiler/​nodeNextPackageSelfNameWithOutDirRootDirCaretDirectory.errors.txt Records type mismatch confirming successful resolution.
tsc/​testdata/​baselines/​reference/​compiler/​nodeNextPackageSelfNameWithOutDirRootDirAtRoot.types Records filesystem-root self-name types.
tsc/​testdata/​baselines/​reference/​compiler/​nodeNextPackageSelfNameWithOutDirRootDirAtRoot.symbols Records filesystem-root self-name symbols.
tsc/​testdata/​baselines/​reference/​compiler/​moduleResolutionAsTypeReferenceDirectiveTrailingSlash.types Records directory-based fallback types.
tsc/​testdata/​baselines/​reference/​compiler/​moduleResolutionAsTypeReferenceDirectiveTrailingSlash.trace.json Records type-root fallback lookup.
tsc/​testdata/​baselines/​reference/​compiler/​moduleResolutionAsTypeReferenceDirectiveTrailingSlash.symbols Records type-root fallback symbols.
tsc/​testdata/​baselines/​reference/​compiler/​moduleResolutionAsTypeReferenceDirectiveTrailingSlash.js Records fallback fixture emit.
tsc/​testdata/​baselines/​reference/​compiler/​moduleResolutionAsTypeReferenceDirectiveTrailingSlash.errors.txt Records exclusion of sibling-file exports.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootUrlWithDotDotSegment.types Records URL map-root fixture types.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootUrlWithDotDotSegment.symbols Records URL map-root fixture symbols.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootUrlWithDotDotSegment.sourcemap.txt Records normalized map URL and mappings.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootUrlWithDotDotSegment.js.map Records source-map JSON.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootUrlWithDotDotSegment.js Records normalized source-map URL comment.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootRelativeCaret.types Records caret map-root fixture types.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootRelativeCaret.symbols Records caret map-root fixture symbols.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootRelativeCaret.sourcemap.txt Records escaped caret URL and relative source.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootRelativeCaret.js.map Records relative source-map path.
tsc/​testdata/​baselines/​reference/​compiler/​mapRootRelativeCaret.js Records escaped caret source-map URL.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitIndexDirectoryOutsideImportingDirectory.types Records types using unambiguous index paths.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitIndexDirectoryOutsideImportingDirectory.symbols Records index-directory symbol resolution.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitIndexDirectoryOutsideImportingDirectory.js Records declarations retaining /index.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsTargetTrailingSlash.types Records types unavailable through directory exports.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsTargetTrailingSlash.symbols Records directory-export fixture symbols.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsTargetTrailingSlash.js Records JavaScript emit without declarations.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsTargetTrailingSlash.errors.txt Records declaration portability diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsPatternTargetTrailingSlash.types Records types unavailable through directory patterns.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsPatternTargetTrailingSlash.symbols Records directory-pattern fixture symbols.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsPatternTargetTrailingSlash.js Records JavaScript emit without declarations.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitExportsPatternTargetTrailingSlash.errors.txt Records pattern-related declaration portability diagnostic.
tsc/​internal/​tsoptions/​extensionsiblings_test.go Tests literal-source precedence over declaration siblings.
tsc/​internal/​outputpaths/​outputpaths_test.go Tests drive-like config filename stems.
tsc/​internal/​module/​resolver_test.go Tests file and directory encoding under dynamic type roots.
tsc/​internal/​ls/​lsconv/​converters_test.go Tests encoded drive-root URI conversion.
tsc/​internal/​fourslash/​tests/​renameFilePackageJson_test.go Tests normalized rename destination URIs.
tsc/​internal/​execute/​tsctests/​tscbuild_test.go Tests builds with no matching inputs.
tsc/​internal/​execute/​tsctests/​tsc_test.go Tests subfolder projects, rooted files, and malformed build info.
tsc/​internal/​execute/​tsctests/​sys.go Adds text replacement that fails on missing targets.
tsc/​internal/​api/​session_program_test.go Tests trailing-slash filenames across API queries.

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 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

2 participants