Skip to content

Restrict content mapper extensions to a single dot - #65284

Draft
Andrew Branch (andrewbranch) wants to merge 1 commit into
microsoft:mainfrom
andrewbranch:content-mapper-single-dot-extensions
Draft

Andrew Branch (andrewbranch) wants to merge 1 commit into
microsoft:mainfrom
andrewbranch:content-mapper-single-dot-extensions

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Content mappers registering extensions with multiple dots like .foo.bar seemed like something I should test when I was writing the initial implementation, but has become a source of surprising complexity, especially in #65047. Since this is something nobody was asking for, and has shockingly confusing interactions with things like moduleSuffixes, I decided it would be better to prohibit it.

@jakebailey

Copy link
Copy Markdown
Member

Would this break say, .tar.gz?

@andrewbranch

Copy link
Copy Markdown
Member Author

Yep, exactly.

@andrewbranch

Copy link
Copy Markdown
Member Author

A compromise that would still reduce the complexity could be to prohibit overlapping extension registrations, e.g. registering both .tar.gz and .gz would be a config error. Currently, the longer extension is treated as more specific.

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 are reported for the changes restricting content mapper source extensions to a single leading dot.

No open issues 🎉

2 files not reviewed
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
  • tsc/testdata/baselines/reference/compiler/contentMapperDeclarationEmit.js: Generated file
What changed in this PR

This PR restricts content mapper source extensions to a single leading dot across the compiler, language server, and VS Code integration. It removes overlapping-extension complexity highlighted by #65047 while preserving compound output suffixes and filenames containing additional dots.

Changes:

  • Reject compound source extensions in registrations and output mapping keys, with matching diagnostics and schema validation.
  • Simplify extension matching, import rewriting, module resolution, and declaration output paths.
  • Replace overlap-specific tests with single-dot validation coverage and update affected baselines.
File Description
tsc/​testdata/​tests/​cases/​compiler/​contentMapperSingleDotExtensions.ts Adds validation and emit regression coverage.
tsc/​testdata/​tests/​cases/​compiler/​contentMapperOutputExtensionsOverlap.ts Removes obsolete overlap test.
tsc/​testdata/​tests/​cases/​compiler/​contentMapperOutputExtensions.ts Uses single-dot sources with dotted filenames.
tsc/​testdata/​tests/​cases/​compiler/​contentMapperDeclarationEmit.ts Updates declaration emit fixture.
tsc/​testdata/​baselines/​reference/​conformance/​emitModuleCommonJS(module=nodenext).js Updates emitted rewrite helper.
tsc/​testdata/​baselines/​reference/​conformance/​emitModuleCommonJS(module=commonjs).js Updates emitted rewrite helper.
tsc/​testdata/​baselines/​reference/​conformance/​emit(jsx=react).js Updates emitted rewrite helper.
tsc/​testdata/​baselines/​reference/​conformance/​emit(jsx=preserve).js Updates emitted rewrite helper.
tsc/​testdata/​baselines/​reference/​compiler/​rewriteRelativeImportExtensionsDynamicImportCjs.js Updates dynamic-import helper baseline.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperSingleDotExtensions.types Records new fixture’s inferred types.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperSingleDotExtensions.symbols Records new fixture’s symbols.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperSingleDotExtensions.js Records import and declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperSingleDotExtensions.errors.txt Records compound-source diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperSingleDotExtensions.contentmapper Records accepted mapper transformations.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensionsOverlap.types Removes obsolete type baseline.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensionsOverlap.symbols Removes obsolete symbol baseline.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensionsOverlap.js Removes obsolete emit baseline.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensionsOverlap.contentmapper Removes obsolete transformation baseline.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensions.types Updates filename and import types.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensions.symbols Updates filename and import symbols.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensions.sourcemap.txt Updates declaration mapping records.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensions.js.map Updates declaration source maps.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensions.js Updates rewritten imports and declarations.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperOutputExtensions.contentmapper Updates registered extensions and filenames.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperDeclarationEmit.types Updates declaration fixture’s type references.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperDeclarationEmit.symbols Updates declaration fixture’s symbol references.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperDeclarationEmit.sourcemap.txt Updates declaration mapping records.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperDeclarationEmit.js.map Updates declaration source maps.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperDeclarationEmit.js Records dotted-filename declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperDeclarationEmit.contentmapper Updates mapper transformation filename.
tsc/​internal/​tspath/​rooted_path.go Removes longest-extension wrapper.
tsc/​internal/​tspath/​path.go Removes longest-extension lookup.
tsc/​internal/​tspath/​path_test.go Removes longest-extension tests.
tsc/​internal/​tspath/​extensionrewrite.go Simplifies rewrite matching and eligibility.
tsc/​internal/​tspath/​extensionrewrite_test.go Updates rewrite and case-sensitivity coverage.
tsc/​internal/​tsoptions/​tsconfigparsing.go Rejects compound registration and mapping sources.
tsc/​internal/​tsoptions/​tsconfigparsing_test.go Updates configuration validation tests.
tsc/​internal/​tsoptions/​parsedcommandline.go Simplifies mapper lookup and rewrite lists.
tsc/​internal/​tsoptions/​contentmappers.go Validates manifest mapping source extensions.
tsc/​internal/​tsoptions/​contentmappers_test.go Updates lookup, caching, and manifest tests.
tsc/​internal/​printer/​helpers.go Simplifies runtime extension rewriting.
tsc/​internal/​outputpaths/​outputpaths.go Simplifies mapped-file and declaration paths.
tsc/​internal/​outputpaths/​outputpaths_test.go Covers dotted filenames and output suffixes.
tsc/​internal/​module/​resolver.go Simplifies candidate extension splitting.
tsc/​internal/​lsp/​server.go Enforces single-dot contribution sources.
tsc/​internal/​lsp/​server_contentmapper_internal_test.go Updates contribution validation coverage.
tsc/​internal/​diagnostics/​diagnostics_generated.go Adds generated single-dot diagnostic.
tsc/​internal/​diagnostics/​diagnosticMessages.json Defines the single-dot diagnostic.
tsc/​internal/​diagnostics/​diagnosticMessages.generated.json Adds generated diagnostic text.
tsc/​internal/​contentmapper/​contentmapper.go Adds source validation and simplifies reserved matching.
tsc/​internal/​checker/​checker.go Uses the final extension in mapper diagnostics.
tools/​scripts/​tsc/​options.test.ts Adds schema rejection cases.
tools/​scripts/​tsc/​options-schema.ts Defines the source-extension schema constraint.
packages/​vscode-typescript/​test/​contentMapperContributions.test.ts Tests source restrictions and compound outputs.
packages/​vscode-typescript/​src/​contentMapperContributions.ts Validates single-dot contribution sources.
packages/​typescript/​schemas/​tsconfig.schema.json Adds source-extension pattern and description.
packages/​typescript/​schemas/​jsconfig.schema.json Adds source-extension pattern and description.

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants