From 8544da101b7c886bc552eeb9020f59ba22af124b Mon Sep 17 00:00:00 2001 From: NullVoxPopuli Date: Tue, 1 Sep 2026 09:50:57 -0400 Subject: [PATCH] Add the outputExtension compiler option Declaration emit names a content-mapped file `counter.d.gts.ts` and keeps `./counter.gts` in specifiers. That is the only safe choice when nothing is known about the external build. When that build compiles `counter.gts` to `counter.js`, the published package needs `counter.d.ts` next to `counter.js`, and `.gts` specifiers do not resolve for consumers that do not run the mapper. The same build compiles `.ts` files, so this is a program-wide setting rather than a per-mapper one. `outputExtension` (".js", ".mjs", or ".cjs") declares what the external build produces for every source file. With it set, declaration emit names each declaration after the output (`.d.ts`, `.d.mts`, `.d.cts`) and rewrites relative specifiers that resolved to a source file by its source extension (`./a.ts`, `./c.gts`) to the output extension. Resolution, not string matching, decides the rewrite, so a specifier that resolved to a sibling `foo.d.gts.ts` is left alone. The option requires noEmit or emitDeclarationOnly (TS5069): the external build owns the JavaScript output, so tsc must not also emit it. Invalid values report TS6046. The name collision from the issue (`app.ts` and `app.gts` both emitting `app.d.ts`) is caught by the existing TS5056 output-path check. Fixes microsoft/TypeScript#64053 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_0188eg6bTrrUiWbj5FZaWH5Z --- tsc/internal/compiler/program.go | 5 + tsc/internal/core/compileroptions.go | 1 + .../diagnostics/diagnostics_generated.go | 4 + .../diagnostics/extraDiagnosticMessages.json | 4 + tsc/internal/outputpaths/outputpaths.go | 25 +- .../testutil/harnessutil/harnessutil.go | 2 +- .../testutil/tsbaseline/js_emit_baseline.go | 2 +- .../transformers/declarations/transform.go | 27 +- tsc/internal/tsoptions/commandlineoption.go | 1 + tsc/internal/tsoptions/declscompiler.go | 9 + tsc/internal/tsoptions/enummaps.go | 6 + tsc/internal/tsoptions/parsinghelpers.go | 2 + .../compiler/outputExtension.contentmapper | 29 ++ .../reference/compiler/outputExtension.js | 59 +++ .../reference/compiler/outputExtension.js.map | 15 + .../compiler/outputExtension.sourcemap.txt | 462 ++++++++++++++++++ .../compiler/outputExtension.symbols | 63 +++ .../reference/compiler/outputExtension.types | 61 +++ .../outputExtensionConflict.contentmapper | 10 + .../outputExtensionConflict.errors.txt | 32 ++ .../compiler/outputExtensionConflict.js | 26 + .../compiler/outputExtensionConflict.symbols | 20 + .../compiler/outputExtensionConflict.types | 21 + .../outputExtensionInvalidValue.errors.txt | 17 + .../compiler/outputExtensionInvalidValue.js | 10 + .../outputExtensionInvalidValue.symbols | 6 + .../outputExtensionInvalidValue.types | 6 + .../reference/compiler/outputExtensionMjs.js | 24 + .../compiler/outputExtensionMjs.symbols | 21 + .../compiler/outputExtensionMjs.types | 21 + ...sionRequiresEmitDeclarationOnly.errors.txt | 16 + ...putExtensionRequiresEmitDeclarationOnly.js | 12 + ...tensionRequiresEmitDeclarationOnly.symbols | 6 + ...ExtensionRequiresEmitDeclarationOnly.types | 6 + .../reference/tsc/commandLine/help-all.js | 5 + .../tests/cases/compiler/outputExtension.ts | 49 ++ .../cases/compiler/outputExtensionConflict.ts | 32 ++ .../compiler/outputExtensionInvalidValue.ts | 11 + .../cases/compiler/outputExtensionMjs.ts | 23 + ...putExtensionRequiresEmitDeclarationOnly.ts | 10 + 40 files changed, 1155 insertions(+), 6 deletions(-) create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtension.contentmapper create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtension.js create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtension.js.map create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtension.sourcemap.txt create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtension.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtension.types create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionConflict.contentmapper create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionConflict.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionConflict.js create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionConflict.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionConflict.types create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.js create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.types create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionMjs.js create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionMjs.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionMjs.types create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.js create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.types create mode 100644 tsc/testdata/tests/cases/compiler/outputExtension.ts create mode 100644 tsc/testdata/tests/cases/compiler/outputExtensionConflict.ts create mode 100644 tsc/testdata/tests/cases/compiler/outputExtensionInvalidValue.ts create mode 100644 tsc/testdata/tests/cases/compiler/outputExtensionMjs.ts create mode 100644 tsc/testdata/tests/cases/compiler/outputExtensionRequiresEmitDeclarationOnly.ts diff --git a/tsc/internal/compiler/program.go b/tsc/internal/compiler/program.go index 34f713918a6ad..2db1000bd20c4 100644 --- a/tsc/internal/compiler/program.go +++ b/tsc/internal/compiler/program.go @@ -1268,6 +1268,11 @@ func (p *Program) verifyCompilerOptions() { } } + // outputExtension describes what an external build emits, so tsc must not emit JavaScript itself. + if options.OutputExtension != "" && !options.NoEmit.IsTrue() && !options.EmitDeclarationOnly.IsTrue() { + createDiagnosticForOptionName(diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "outputExtension", "noEmit", "emitDeclarationOnly") + } + moduleKind := options.GetEmitModuleKind() if options.AllowImportingTsExtensions.IsTrue() && !(options.NoEmit.IsTrue() || options.EmitDeclarationOnly.IsTrue() || options.RewriteRelativeImportExtensions.IsTrue()) { diff --git a/tsc/internal/core/compileroptions.go b/tsc/internal/core/compileroptions.go index 55401a499f3a8..0770a410138b8 100644 --- a/tsc/internal/core/compileroptions.go +++ b/tsc/internal/core/compileroptions.go @@ -83,6 +83,7 @@ type CompilerOptions struct { NoImplicitOverride Tristate `json:"noImplicitOverride,omitzero"` NoUncheckedSideEffectImports Tristate `json:"noUncheckedSideEffectImports,omitzero"` OutDir string `json:"outDir,omitzero"` + OutputExtension string `json:"outputExtension,omitzero"` Paths *collections.OrderedMap[string, []string] `json:"paths,omitzero"` PreserveConstEnums Tristate `json:"preserveConstEnums,omitzero"` PreserveSymlinks Tristate `json:"preserveSymlinks,omitzero"` diff --git a/tsc/internal/diagnostics/diagnostics_generated.go b/tsc/internal/diagnostics/diagnostics_generated.go index e5f35543f1674..ec00c2b721556 100644 --- a/tsc/internal/diagnostics/diagnostics_generated.go +++ b/tsc/internal/diagnostics/diagnostics_generated.go @@ -4422,6 +4422,8 @@ var The_invalid_diagnostic_directive_is_in_supplemental_output_0_returned_by_the var Diagnostic_directive_0_returned_by_the_content_mapper_has_an_invalid_unusedExpectDirectiveIndex = &Message{code: 100068, category: CategoryMessage, key: "Diagnostic_directive_0_returned_by_the_content_mapper_has_an_invalid_unusedExpectDirectiveIndex_100068", text: "Diagnostic directive {0} returned by the content mapper has an invalid 'unusedExpectDirectiveIndex'."} +var Specify_the_file_extension_that_an_external_build_gives_every_source_file_so_that_declaration_file_names_and_their_relative_imports_match_the_build_output = &Message{code: 100069, category: CategoryMessage, key: "Specify_the_file_extension_that_an_external_build_gives_every_source_file_so_that_declaration_file_n_100069", text: "Specify the file extension that an external build gives every source file, so that declaration file names and their relative imports match the build output."} + func keyToMessage(key Key) *Message { switch key { case "Unterminated_string_literal_1002": @@ -8844,6 +8846,8 @@ func keyToMessage(key Key) *Message { return The_invalid_diagnostic_directive_is_in_supplemental_output_0_returned_by_the_content_mapper case "Diagnostic_directive_0_returned_by_the_content_mapper_has_an_invalid_unusedExpectDirectiveIndex_100068": return Diagnostic_directive_0_returned_by_the_content_mapper_has_an_invalid_unusedExpectDirectiveIndex + case "Specify_the_file_extension_that_an_external_build_gives_every_source_file_so_that_declaration_file_n_100069": + return Specify_the_file_extension_that_an_external_build_gives_every_source_file_so_that_declaration_file_names_and_their_relative_imports_match_the_build_output default: return nil } diff --git a/tsc/internal/diagnostics/extraDiagnosticMessages.json b/tsc/internal/diagnostics/extraDiagnosticMessages.json index 41c7b8d8abc35..2c23abffb768d 100644 --- a/tsc/internal/diagnostics/extraDiagnosticMessages.json +++ b/tsc/internal/diagnostics/extraDiagnosticMessages.json @@ -338,5 +338,9 @@ "Diagnostic directive {0} returned by the content mapper has an invalid 'unusedExpectDirectiveIndex'.": { "category": "Message", "code": 100068 + }, + "Specify the file extension that an external build gives every source file, so that declaration file names and their relative imports match the build output.": { + "category": "Message", + "code": 100069 } } diff --git a/tsc/internal/outputpaths/outputpaths.go b/tsc/internal/outputpaths/outputpaths.go index 83a098654063f..2e065c7a03113 100644 --- a/tsc/internal/outputpaths/outputpaths.go +++ b/tsc/internal/outputpaths/outputpaths.go @@ -110,7 +110,7 @@ func GetOutputDeclarationFileNameWorker(inputFileName string, options *core.Comp if len(dir) == 0 { dir = options.OutDir } - return ChangeToDeclarationExtension(getOutputPathWithoutChangingExtension(inputFileName, dir, host), host) + return ChangeToDeclarationExtension(getOutputPathWithoutChangingExtension(inputFileName, dir, host), options, host) } func GetOutputExtension(fileName string, jsx core.JsxEmit) string { @@ -142,11 +142,14 @@ func GetDeclarationEmitOutputFilePath(file string, options *core.CompilerOptions } else { path = file } - return ChangeToDeclarationExtension(path, host) + return ChangeToDeclarationExtension(path, options, host) } -func ChangeToDeclarationExtension(path string, host OutputPathsHost) string { +func ChangeToDeclarationExtension(path string, options *core.CompilerOptions, host OutputPathsHost) string { if extension := tspath.GetLongestExtensionFromPath(path, host.ContentMapperExtensions(), false); extension != "" { + if options.OutputExtension != "" { + return tspath.RemoveExtension(path, extension) + DeclarationExtensionForOutput(options.OutputExtension) + } return tspath.RemoveExtension(path, extension) + ".d" + extension + ".ts" } pathWithoutExtension := tspath.RemoveFileExtension(path) @@ -155,9 +158,25 @@ func ChangeToDeclarationExtension(path string, host OutputPathsHost) string { pathWithoutExtension = tspath.RemoveExtension(path, extension) } } + if options.OutputExtension != "" { + return pathWithoutExtension + DeclarationExtensionForOutput(options.OutputExtension) + } return pathWithoutExtension + tspath.GetDeclarationEmitExtensionForPath(path) } +// DeclarationExtensionForOutput returns the declaration extension that sits next to a JavaScript file +// with the given extension, for the values that outputExtension accepts. +func DeclarationExtensionForOutput(outputExtension string) string { + switch outputExtension { + case tspath.ExtensionMjs: + return tspath.ExtensionDmts + case tspath.ExtensionCjs: + return tspath.ExtensionDcts + default: + return tspath.ExtensionDts + } +} + func GetSourceFilePathInNewDir(fileName string, newDirPath string, currentDirectory string, commonSourceDirectory string, useCaseSensitiveFileNames bool) string { return GetSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, useCaseSensitiveFileNames) } diff --git a/tsc/internal/testutil/harnessutil/harnessutil.go b/tsc/internal/testutil/harnessutil/harnessutil.go index b4209fb9bac47..6385b8811bf00 100644 --- a/tsc/internal/testutil/harnessutil/harnessutil.go +++ b/tsc/internal/testutil/harnessutil/harnessutil.go @@ -855,7 +855,7 @@ func (c *CompilationResult) getOutputPath(path string, ext string) string { } } if ext == tspath.GetDeclarationEmitExtensionForPath(path) { - return outputpaths.ChangeToDeclarationExtension(path, c.Program.Program()) + return outputpaths.ChangeToDeclarationExtension(path, c.Program.Program().Options(), c.Program.Program()) } return tspath.ChangeExtension(path, ext) } diff --git a/tsc/internal/testutil/tsbaseline/js_emit_baseline.go b/tsc/internal/testutil/tsbaseline/js_emit_baseline.go index aaee3fb601fdd..ff4830eddd9f0 100644 --- a/tsc/internal/testutil/tsbaseline/js_emit_baseline.go +++ b/tsc/internal/testutil/tsbaseline/js_emit_baseline.go @@ -216,7 +216,7 @@ func prepareDeclarationCompilationContext( sourceFileName = sourceFile.FileName() } - dTsFileName := outputpaths.ChangeToDeclarationExtension(sourceFileName, result.Program.Program()) + dTsFileName := outputpaths.ChangeToDeclarationExtension(sourceFileName, result.Program.Program().Options(), result.Program.Program()) return result.DTS.GetOrZero(dTsFileName) } diff --git a/tsc/internal/transformers/declarations/transform.go b/tsc/internal/transformers/declarations/transform.go index 32fa0201a9ef5..5574f2d427935 100644 --- a/tsc/internal/transformers/declarations/transform.go +++ b/tsc/internal/transformers/declarations/transform.go @@ -1592,7 +1592,32 @@ func (tx *DeclarationTransformer) rewriteModuleSpecifier(parent *ast.Node, input return nil } tx.resultHasExternalModuleIndicator = tx.resultHasExternalModuleIndicator || (parent.Kind != ast.KindModuleDeclaration && parent.Kind != ast.KindImportType) - return input + return tx.rewriteSpecifierToOutputExtension(input) +} + +// rewriteSpecifierToOutputExtension rewrites a relative specifier that resolved to a source file by its +// source extension (`./a.ts`, `./b.vue`) to the extension the external build gives that file, so the +// specifier resolves against the declaration file emitted next to the build output. +func (tx *DeclarationTransformer) rewriteSpecifierToOutputExtension(input *ast.Node) *ast.Node { + outputExtension := tx.compilerOptions.OutputExtension + if outputExtension == "" || !ast.IsStringLiteral(input) || !tspath.PathIsRelative(input.Text()) { + return input + } + resolved := tx.host.GetResolvedModuleFromModuleSpecifier(tx.state.currentSourceFile, input) + if resolved == nil || !resolved.IsResolved() || !(resolved.ResolvedUsingTsExtension || resolved.ResolvedUsingExtraExtensions) { + return input + } + extension := tspath.GetLongestExtensionFromPath(input.Text(), tx.host.ContentMapperExtensions(), !tx.host.UseCaseSensitiveFileNames()) + if extension == "" { + extension = tspath.TryExtractTSExtension(input.Text()) + } + if extension == "" { + return input + } + updated := tx.Factory().NewStringLiteral(tspath.RemoveExtension(input.Text(), extension)+outputExtension, input.AsStringLiteral().TokenFlags) + tx.EmitContext().SetOriginal(updated, input) + tx.EmitContext().AssignCommentAndSourceMapRanges(updated, input) + return updated } func (tx *DeclarationTransformer) preserveJsDoc(updated *ast.Node, original *ast.Node) { diff --git a/tsc/internal/tsoptions/commandlineoption.go b/tsc/internal/tsoptions/commandlineoption.go index 1346e5c0bbd5e..b03279e020f0f 100644 --- a/tsc/internal/tsoptions/commandlineoption.go +++ b/tsc/internal/tsoptions/commandlineoption.go @@ -188,6 +188,7 @@ var commandLineOptionEnumMap = map[string]*collections.OrderedMap[string, any]{ "moduleDetection": moduleDetectionOptionMap, "jsx": jsxOptionMap, "newLine": newLineOptionMap, + "outputExtension": outputExtensionOptionMap, "watchFile": watchFileEnumMap, "watchDirectory": watchDirectoryEnumMap, "fallbackPolling": fallbackEnumMap, diff --git a/tsc/internal/tsoptions/declscompiler.go b/tsc/internal/tsoptions/declscompiler.go index 46fb42faee7c5..b61f124a44df7 100644 --- a/tsc/internal/tsoptions/declscompiler.go +++ b/tsc/internal/tsoptions/declscompiler.go @@ -1129,6 +1129,15 @@ var optionsForCompiler = []*CommandLineOption{ transpileOptionValue: core.TSUnknown, Description: diagnostics.Specify_the_output_directory_for_generated_declaration_files, }, + { + Name: "outputExtension", + Kind: CommandLineOptionTypeEnum, // outputExtensionOptionMap, + AffectsEmit: true, + AffectsBuildInfo: true, + AffectsDeclarationPath: true, + Category: diagnostics.Emit, + Description: diagnostics.Specify_the_file_extension_that_an_external_build_gives_every_source_file_so_that_declaration_file_names_and_their_relative_imports_match_the_build_output, + }, { Name: "skipLibCheck", Kind: CommandLineOptionTypeBoolean, diff --git a/tsc/internal/tsoptions/enummaps.go b/tsc/internal/tsoptions/enummaps.go index 3bf67a8640675..22decfaaf25eb 100644 --- a/tsc/internal/tsoptions/enummaps.go +++ b/tsc/internal/tsoptions/enummaps.go @@ -204,6 +204,12 @@ var newLineOptionMap = collections.NewOrderedMapFromList([]collections.MapEntry[ {Key: "lf", Value: core.NewLineKindLF}, }) +var outputExtensionOptionMap = collections.NewOrderedMapFromList([]collections.MapEntry[string, any]{ + {Key: ".js", Value: ".js"}, + {Key: ".mjs", Value: ".mjs"}, + {Key: ".cjs", Value: ".cjs"}, +}) + var targetToLibMap = map[core.ScriptTarget]string{ core.ScriptTargetESNext: "lib.esnext.full.d.ts", core.ScriptTargetES2025: "lib.es2025.full.d.ts", diff --git a/tsc/internal/tsoptions/parsinghelpers.go b/tsc/internal/tsoptions/parsinghelpers.go index fa7491b1e0c06..5861240c20cea 100644 --- a/tsc/internal/tsoptions/parsinghelpers.go +++ b/tsc/internal/tsoptions/parsinghelpers.go @@ -444,6 +444,8 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption allOptions.NoUncheckedSideEffectImports = ParseTristate(value) case "outFile": allOptions.OutFile = ParseString(value) + case "outputExtension": + allOptions.OutputExtension = ParseString(value) case "noResolve": allOptions.NoResolve = ParseTristate(value) case "paths": diff --git a/tsc/testdata/baselines/reference/compiler/outputExtension.contentmapper b/tsc/testdata/baselines/reference/compiler/outputExtension.contentmapper new file mode 100644 index 0000000000000..af3667ca5da8b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtension.contentmapper @@ -0,0 +1,29 @@ +//// [/other.p] (ScriptKind: ScriptKindTS, ContentMapper: [.y.z .p]) +--- Original --- +export declare const other: number; +--- Transformed --- +const __VERSION = "1.0.0"; +export declare const other: number; + +//// [/component.y.z] (ScriptKind: ScriptKindTS, ContentMapper: [.y.z .p]) +--- Original --- +import { helper } from "./helper.ts"; +import { other } from "./other.p"; +export interface ComponentProps { + label: typeof helper; + count: typeof other; +} +export declare const component: ComponentProps; +--- Transformed --- +const __VERSION = "1.0.0"; +import { helper } from "./helper.ts"; +import { other } from "./other.p"; +export interface ComponentProps { + label: typeof helper; + count: typeof other; +} +export declare const component: ComponentProps; + +=== Diagnostics === + + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtension.js b/tsc/testdata/baselines/reference/compiler/outputExtension.js new file mode 100644 index 0000000000000..10d550d131344 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtension.js @@ -0,0 +1,59 @@ +//// [tests/cases/compiler/outputExtension.ts] //// + +//// [package.json] +{ + "name": "mapper", + "version": "1.0.0", + "typescript": { "contentMapper": { "exec": ["compiler-test-mapper"] } } +} + +//// [helper.ts] +export declare const helper: string; + +//// [other.p] +const __VERSION = "1.0.0"; +export declare const other: number; + +//// [component.y.z] +const __VERSION = "1.0.0"; +import { helper } from "./helper.ts"; +import { other } from "./other.p"; +export interface ComponentProps { + label: typeof helper; + count: typeof other; +} +export declare const component: ComponentProps; + +//// [main.ts] +export { component } from "./component.y.z"; +export type { ComponentProps } from "./component.y.z"; +export type Props = import("./component.y.z").ComponentProps; +export * as other from "./other.p"; +export { helper } from "./helper.ts"; +export { helper as helperJs } from "./helper.js"; +export { helper as helperBare } from "./helper"; + + + + +//// [helper.d.ts] +export declare const helper: string; +//# sourceMappingURL=helper.d.ts.map//// [other.d.ts] +export declare const other: number; +//# sourceMappingURL=other.d.ts.map//// [component.d.ts] +import { helper } from "./helper.js"; +import { other } from "./other.js"; +export interface ComponentProps { + label: typeof helper; + count: typeof other; +} +export declare const component: ComponentProps; +//# sourceMappingURL=component.d.ts.map//// [main.d.ts] +export { component } from "./component.js"; +export type { ComponentProps } from "./component.js"; +export type Props = import("./component.js").ComponentProps; +export * as other from "./other.js"; +export { helper } from "./helper.js"; +export { helper as helperJs } from "./helper.js"; +export { helper as helperBare } from "./helper"; +//# sourceMappingURL=main.d.ts.map \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/outputExtension.js.map b/tsc/testdata/baselines/reference/compiler/outputExtension.js.map new file mode 100644 index 0000000000000..da84b6533cc46 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtension.js.map @@ -0,0 +1,15 @@ +//// [component.d.ts.map] +{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["component.y.z"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAW,CAAC;AAClC,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,OAAO,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,KAAK,CAAC;CACvB;AACD,MAAM,CAAC,OAAO,CAAC,MAAM,SAAS,EAAE,cAAc,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,aW1wb3J0IHsgaGVscGVyIH0gZnJvbSAiLi9oZWxwZXIuanMiOw0KaW1wb3J0IHsgb3RoZXIgfSBmcm9tICIuL290aGVyLmpzIjsNCmV4cG9ydCBpbnRlcmZhY2UgQ29tcG9uZW50UHJvcHMgew0KICAgIGxhYmVsOiB0eXBlb2YgaGVscGVyOw0KICAgIGNvdW50OiB0eXBlb2Ygb3RoZXI7DQp9DQpleHBvcnQgZGVjbGFyZSBjb25zdCBjb21wb25lbnQ6IENvbXBvbmVudFByb3BzOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9Y29tcG9uZW50LmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcG9uZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJjb21wb25lbnQueS56Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFDckMsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLFlBQVcsQ0FBQztBQUNsQyxNQUFNLFdBQVcsY0FBYztJQUMzQixLQUFLLEVBQUUsT0FBTyxNQUFNLENBQUM7SUFDckIsS0FBSyxFQUFFLE9BQU8sS0FBSyxDQUFDO0NBQ3ZCO0FBQ0QsTUFBTSxDQUFDLE9BQU8sQ0FBQyxNQUFNLFNBQVMsRUFBRSxjQUFjLENBQUMifQ==,aW1wb3J0IHsgaGVscGVyIH0gZnJvbSAiLi9oZWxwZXIudHMiOwppbXBvcnQgeyBvdGhlciB9IGZyb20gIi4vb3RoZXIucCI7CmV4cG9ydCBpbnRlcmZhY2UgQ29tcG9uZW50UHJvcHMgewogICAgbGFiZWw6IHR5cGVvZiBoZWxwZXI7CiAgICBjb3VudDogdHlwZW9mIG90aGVyOwp9CmV4cG9ydCBkZWNsYXJlIGNvbnN0IGNvbXBvbmVudDogQ29tcG9uZW50UHJvcHM7Cg== + +//// [helper.d.ts.map] +{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["helper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,ZXhwb3J0IGRlY2xhcmUgY29uc3QgaGVscGVyOiBzdHJpbmc7DQovLyMgc291cmNlTWFwcGluZ1VSTD1oZWxwZXIuZC50cy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJoZWxwZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFDLE9BQU8sQ0FBQyxNQUFNLE1BQU0sRUFBRSxNQUFNLENBQUMifQ==,ZXhwb3J0IGRlY2xhcmUgY29uc3QgaGVscGVyOiBzdHJpbmc7Cg== + +//// [main.d.ts.map] +{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAiB,CAAC;AACtD,MAAM,MAAM,KAAK,GAAG,OAAO,gBAAiB,EAAE,cAAc,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,YAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,ZXhwb3J0IHsgY29tcG9uZW50IH0gZnJvbSAiLi9jb21wb25lbnQuanMiOw0KZXhwb3J0IHR5cGUgeyBDb21wb25lbnRQcm9wcyB9IGZyb20gIi4vY29tcG9uZW50LmpzIjsNCmV4cG9ydCB0eXBlIFByb3BzID0gaW1wb3J0KCIuL2NvbXBvbmVudC5qcyIpLkNvbXBvbmVudFByb3BzOw0KZXhwb3J0ICogYXMgb3RoZXIgZnJvbSAiLi9vdGhlci5qcyI7DQpleHBvcnQgeyBoZWxwZXIgfSBmcm9tICIuL2hlbHBlci5qcyI7DQpleHBvcnQgeyBoZWxwZXIgYXMgaGVscGVySnMgfSBmcm9tICIuL2hlbHBlci5qcyI7DQpleHBvcnQgeyBoZWxwZXIgYXMgaGVscGVyQmFyZSB9IGZyb20gIi4vaGVscGVyIjsNCi8vIyBzb3VyY2VNYXBwaW5nVVJMPW1haW4uZC50cy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibWFpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sZ0JBQWlCLENBQUM7QUFDNUMsWUFBWSxFQUFFLGNBQWMsRUFBRSxNQUFNLGdCQUFpQixDQUFDO0FBQ3RELE1BQU0sTUFBTSxLQUFLLEdBQUcsT0FBTyxnQkFBaUIsRUFBRSxjQUFjLENBQUM7QUFDN0QsT0FBTyxLQUFLLEtBQUssTUFBTSxZQUFXLENBQUM7QUFDbkMsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUNyQyxPQUFPLEVBQUUsTUFBTSxJQUFJLFFBQVEsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUNqRCxPQUFPLEVBQUUsTUFBTSxJQUFJLFVBQVUsRUFBRSxNQUFNLFVBQVUsQ0FBQyJ9,ZXhwb3J0IHsgY29tcG9uZW50IH0gZnJvbSAiLi9jb21wb25lbnQueS56IjsKZXhwb3J0IHR5cGUgeyBDb21wb25lbnRQcm9wcyB9IGZyb20gIi4vY29tcG9uZW50LnkueiI7CmV4cG9ydCB0eXBlIFByb3BzID0gaW1wb3J0KCIuL2NvbXBvbmVudC55LnoiKS5Db21wb25lbnRQcm9wczsKZXhwb3J0ICogYXMgb3RoZXIgZnJvbSAiLi9vdGhlci5wIjsKZXhwb3J0IHsgaGVscGVyIH0gZnJvbSAiLi9oZWxwZXIudHMiOwpleHBvcnQgeyBoZWxwZXIgYXMgaGVscGVySnMgfSBmcm9tICIuL2hlbHBlci5qcyI7CmV4cG9ydCB7IGhlbHBlciBhcyBoZWxwZXJCYXJlIH0gZnJvbSAiLi9oZWxwZXIiOwo= + +//// [other.d.ts.map] +{"version":3,"file":"other.d.ts","sourceRoot":"","sources":["other.p"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,EAAE,MAAM,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,ZXhwb3J0IGRlY2xhcmUgY29uc3Qgb3RoZXI6IG51bWJlcjsNCi8vIyBzb3VyY2VNYXBwaW5nVVJMPW90aGVyLmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3RoZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm90aGVyLnAiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFDLE9BQU8sQ0FBQyxNQUFNLEtBQUssRUFBRSxNQUFNLENBQUMifQ==,ZXhwb3J0IGRlY2xhcmUgY29uc3Qgb3RoZXI6IG51bWJlcjsK diff --git a/tsc/testdata/baselines/reference/compiler/outputExtension.sourcemap.txt b/tsc/testdata/baselines/reference/compiler/outputExtension.sourcemap.txt new file mode 100644 index 0000000000000..d5b858e4bf801 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtension.sourcemap.txt @@ -0,0 +1,462 @@ +=================================================================== +JsFile: helper.d.ts +mapUrl: helper.d.ts.map +sourceRoot: +sources: helper.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:/helper.d.ts +sourceFile:helper.ts +------------------------------------------------------------------- +>>>export declare const helper: string; +1 > +2 >^^^^^^ +3 > ^ +4 > ^^^^^^^ +5 > ^ +6 > ^^^^^^ +7 > ^^^^^^ +8 > ^^ +9 > ^^^^^^ +10> ^ +1 > +2 >export +3 > +4 > declare +5 > +6 > const +7 > helper +8 > : +9 > string +10> ; +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 7) Source(1, 7) + SourceIndex(0) +3 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) +4 >Emitted(1, 15) Source(1, 15) + SourceIndex(0) +5 >Emitted(1, 16) Source(1, 16) + SourceIndex(0) +6 >Emitted(1, 22) Source(1, 22) + SourceIndex(0) +7 >Emitted(1, 28) Source(1, 28) + SourceIndex(0) +8 >Emitted(1, 30) Source(1, 30) + SourceIndex(0) +9 >Emitted(1, 36) Source(1, 36) + SourceIndex(0) +10>Emitted(1, 37) Source(1, 37) + SourceIndex(0) +--- +>>>//# sourceMappingURL=helper.d.ts.map=================================================================== +JsFile: other.d.ts +mapUrl: other.d.ts.map +sourceRoot: +sources: other.p +=================================================================== +------------------------------------------------------------------- +emittedFile:/other.d.ts +sourceFile:other.p +------------------------------------------------------------------- +>>>export declare const other: number; +1 > +2 >^^^^^^ +3 > ^ +4 > ^^^^^^^ +5 > ^ +6 > ^^^^^^ +7 > ^^^^^ +8 > ^^ +9 > ^^^^^^ +10> ^ +1 > +2 >export +3 > +4 > declare +5 > +6 > const +7 > other +8 > : +9 > number +10> ; +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 7) Source(1, 7) + SourceIndex(0) +3 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) +4 >Emitted(1, 15) Source(1, 15) + SourceIndex(0) +5 >Emitted(1, 16) Source(1, 16) + SourceIndex(0) +6 >Emitted(1, 22) Source(1, 22) + SourceIndex(0) +7 >Emitted(1, 27) Source(1, 27) + SourceIndex(0) +8 >Emitted(1, 29) Source(1, 29) + SourceIndex(0) +9 >Emitted(1, 35) Source(1, 35) + SourceIndex(0) +10>Emitted(1, 36) Source(1, 36) + SourceIndex(0) +--- +>>>//# sourceMappingURL=other.d.ts.map=================================================================== +JsFile: component.d.ts +mapUrl: component.d.ts.map +sourceRoot: +sources: component.y.z +=================================================================== +------------------------------------------------------------------- +emittedFile:/component.d.ts +sourceFile:component.y.z +------------------------------------------------------------------- +>>>import { helper } from "./helper.js"; +1 > +2 >^^^^^^^ +3 > ^^ +4 > ^^^^^^ +5 > ^^ +6 > ^^^^^^ +7 > ^^^^^^^^^^^^^ +8 > ^ +1 > +2 >import +3 > { +4 > helper +5 > } +6 > from +7 > "./helper.ts" +8 > ; +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) +3 >Emitted(1, 10) Source(1, 10) + SourceIndex(0) +4 >Emitted(1, 16) Source(1, 16) + SourceIndex(0) +5 >Emitted(1, 18) Source(1, 18) + SourceIndex(0) +6 >Emitted(1, 24) Source(1, 24) + SourceIndex(0) +7 >Emitted(1, 37) Source(1, 37) + SourceIndex(0) +8 >Emitted(1, 38) Source(1, 38) + SourceIndex(0) +--- +>>>import { other } from "./other.js"; +1 > +2 >^^^^^^^ +3 > ^^ +4 > ^^^^^ +5 > ^^ +6 > ^^^^^^ +7 > ^^^^^^^^^^^^ +8 > ^ +1 > + > +2 >import +3 > { +4 > other +5 > } +6 > from +7 > "./other.p" +8 > ; +1 >Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 8) Source(2, 8) + SourceIndex(0) +3 >Emitted(2, 10) Source(2, 10) + SourceIndex(0) +4 >Emitted(2, 15) Source(2, 15) + SourceIndex(0) +5 >Emitted(2, 17) Source(2, 17) + SourceIndex(0) +6 >Emitted(2, 23) Source(2, 23) + SourceIndex(0) +7 >Emitted(2, 35) Source(2, 34) + SourceIndex(0) +8 >Emitted(2, 36) Source(2, 35) + SourceIndex(0) +--- +>>>export interface ComponentProps { +1 > +2 >^^^^^^ +3 > ^^^^^^^^^^^ +4 > ^^^^^^^^^^^^^^ +1 > + > +2 >export +3 > interface +4 > ComponentProps +1 >Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) +4 >Emitted(3, 32) Source(3, 32) + SourceIndex(0) +--- +>>> label: typeof helper; +1 >^^^^ +2 > ^^^^^ +3 > ^^ +4 > ^^^^^^^ +5 > ^^^^^^ +6 > ^ +1 > { + > +2 > label +3 > : +4 > typeof +5 > helper +6 > ; +1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) +2 >Emitted(4, 10) Source(4, 10) + SourceIndex(0) +3 >Emitted(4, 12) Source(4, 12) + SourceIndex(0) +4 >Emitted(4, 19) Source(4, 19) + SourceIndex(0) +5 >Emitted(4, 25) Source(4, 25) + SourceIndex(0) +6 >Emitted(4, 26) Source(4, 26) + SourceIndex(0) +--- +>>> count: typeof other; +1 >^^^^ +2 > ^^^^^ +3 > ^^ +4 > ^^^^^^^ +5 > ^^^^^ +6 > ^ +1 > + > +2 > count +3 > : +4 > typeof +5 > other +6 > ; +1 >Emitted(5, 5) Source(5, 5) + SourceIndex(0) +2 >Emitted(5, 10) Source(5, 10) + SourceIndex(0) +3 >Emitted(5, 12) Source(5, 12) + SourceIndex(0) +4 >Emitted(5, 19) Source(5, 19) + SourceIndex(0) +5 >Emitted(5, 24) Source(5, 24) + SourceIndex(0) +6 >Emitted(5, 25) Source(5, 25) + SourceIndex(0) +--- +>>>} +1 >^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + >} +1 >Emitted(6, 2) Source(6, 2) + SourceIndex(0) +--- +>>>export declare const component: ComponentProps; +1-> +2 >^^^^^^ +3 > ^ +4 > ^^^^^^^ +5 > ^ +6 > ^^^^^^ +7 > ^^^^^^^^^ +8 > ^^ +9 > ^^^^^^^^^^^^^^ +10> ^ +1-> + > +2 >export +3 > +4 > declare +5 > +6 > const +7 > component +8 > : +9 > ComponentProps +10> ; +1->Emitted(7, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(7, 7) Source(7, 7) + SourceIndex(0) +3 >Emitted(7, 8) Source(7, 8) + SourceIndex(0) +4 >Emitted(7, 15) Source(7, 15) + SourceIndex(0) +5 >Emitted(7, 16) Source(7, 16) + SourceIndex(0) +6 >Emitted(7, 22) Source(7, 22) + SourceIndex(0) +7 >Emitted(7, 31) Source(7, 31) + SourceIndex(0) +8 >Emitted(7, 33) Source(7, 33) + SourceIndex(0) +9 >Emitted(7, 47) Source(7, 47) + SourceIndex(0) +10>Emitted(7, 48) Source(7, 48) + SourceIndex(0) +--- +>>>//# sourceMappingURL=component.d.ts.map=================================================================== +JsFile: main.d.ts +mapUrl: main.d.ts.map +sourceRoot: +sources: main.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:/main.d.ts +sourceFile:main.ts +------------------------------------------------------------------- +>>>export { component } from "./component.js"; +1 > +2 >^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^ +5 > ^^ +6 > ^^^^^^ +7 > ^^^^^^^^^^^^^^^^ +8 > ^ +9 > ^^^^^^^^^^^-> +1 > +2 >export +3 > { +4 > component +5 > } +6 > from +7 > "./component.y.z" +8 > ; +1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) +3 >Emitted(1, 10) Source(1, 10) + SourceIndex(0) +4 >Emitted(1, 19) Source(1, 19) + SourceIndex(0) +5 >Emitted(1, 21) Source(1, 21) + SourceIndex(0) +6 >Emitted(1, 27) Source(1, 27) + SourceIndex(0) +7 >Emitted(1, 43) Source(1, 44) + SourceIndex(0) +8 >Emitted(1, 44) Source(1, 45) + SourceIndex(0) +--- +>>>export type { ComponentProps } from "./component.js"; +1-> +2 >^^^^^^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^^^^^^ +5 > ^^ +6 > ^^^^^^ +7 > ^^^^^^^^^^^^^^^^ +8 > ^ +9 > ^^^^^^^^-> +1-> + > +2 >export type +3 > { +4 > ComponentProps +5 > } +6 > from +7 > "./component.y.z" +8 > ; +1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) +3 >Emitted(2, 15) Source(2, 15) + SourceIndex(0) +4 >Emitted(2, 29) Source(2, 29) + SourceIndex(0) +5 >Emitted(2, 31) Source(2, 31) + SourceIndex(0) +6 >Emitted(2, 37) Source(2, 37) + SourceIndex(0) +7 >Emitted(2, 53) Source(2, 54) + SourceIndex(0) +8 >Emitted(2, 54) Source(2, 55) + SourceIndex(0) +--- +>>>export type Props = import("./component.js").ComponentProps; +1-> +2 >^^^^^^ +3 > ^^^^^^ +4 > ^^^^^ +5 > ^^^ +6 > ^^^^^^^ +7 > ^^^^^^^^^^^^^^^^ +8 > ^^ +9 > ^^^^^^^^^^^^^^ +10> ^ +1-> + > +2 >export +3 > type +4 > Props +5 > = +6 > import( +7 > "./component.y.z" +8 > ). +9 > ComponentProps +10> ; +1->Emitted(3, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(3, 7) Source(3, 7) + SourceIndex(0) +3 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +4 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) +5 >Emitted(3, 21) Source(3, 21) + SourceIndex(0) +6 >Emitted(3, 28) Source(3, 28) + SourceIndex(0) +7 >Emitted(3, 44) Source(3, 45) + SourceIndex(0) +8 >Emitted(3, 46) Source(3, 47) + SourceIndex(0) +9 >Emitted(3, 60) Source(3, 61) + SourceIndex(0) +10>Emitted(3, 61) Source(3, 62) + SourceIndex(0) +--- +>>>export * as other from "./other.js"; +1 > +2 >^^^^^^^ +3 > ^^^^^ +4 > ^^^^^ +5 > ^^^^^^ +6 > ^^^^^^^^^^^^ +7 > ^ +8 > ^^-> +1 > + > +2 >export +3 > * as +4 > other +5 > from +6 > "./other.p" +7 > ; +1 >Emitted(4, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(4, 8) Source(4, 8) + SourceIndex(0) +3 >Emitted(4, 13) Source(4, 13) + SourceIndex(0) +4 >Emitted(4, 18) Source(4, 18) + SourceIndex(0) +5 >Emitted(4, 24) Source(4, 24) + SourceIndex(0) +6 >Emitted(4, 36) Source(4, 35) + SourceIndex(0) +7 >Emitted(4, 37) Source(4, 36) + SourceIndex(0) +--- +>>>export { helper } from "./helper.js"; +1-> +2 >^^^^^^^ +3 > ^^ +4 > ^^^^^^ +5 > ^^ +6 > ^^^^^^ +7 > ^^^^^^^^^^^^^ +8 > ^ +9 > ^^^^^^^^^^^^^-> +1-> + > +2 >export +3 > { +4 > helper +5 > } +6 > from +7 > "./helper.ts" +8 > ; +1->Emitted(5, 1) Source(5, 1) + SourceIndex(0) +2 >Emitted(5, 8) Source(5, 8) + SourceIndex(0) +3 >Emitted(5, 10) Source(5, 10) + SourceIndex(0) +4 >Emitted(5, 16) Source(5, 16) + SourceIndex(0) +5 >Emitted(5, 18) Source(5, 18) + SourceIndex(0) +6 >Emitted(5, 24) Source(5, 24) + SourceIndex(0) +7 >Emitted(5, 37) Source(5, 37) + SourceIndex(0) +8 >Emitted(5, 38) Source(5, 38) + SourceIndex(0) +--- +>>>export { helper as helperJs } from "./helper.js"; +1-> +2 >^^^^^^^ +3 > ^^ +4 > ^^^^^^ +5 > ^^^^ +6 > ^^^^^^^^ +7 > ^^ +8 > ^^^^^^ +9 > ^^^^^^^^^^^^^ +10> ^ +1-> + > +2 >export +3 > { +4 > helper +5 > as +6 > helperJs +7 > } +8 > from +9 > "./helper.js" +10> ; +1->Emitted(6, 1) Source(6, 1) + SourceIndex(0) +2 >Emitted(6, 8) Source(6, 8) + SourceIndex(0) +3 >Emitted(6, 10) Source(6, 10) + SourceIndex(0) +4 >Emitted(6, 16) Source(6, 16) + SourceIndex(0) +5 >Emitted(6, 20) Source(6, 20) + SourceIndex(0) +6 >Emitted(6, 28) Source(6, 28) + SourceIndex(0) +7 >Emitted(6, 30) Source(6, 30) + SourceIndex(0) +8 >Emitted(6, 36) Source(6, 36) + SourceIndex(0) +9 >Emitted(6, 49) Source(6, 49) + SourceIndex(0) +10>Emitted(6, 50) Source(6, 50) + SourceIndex(0) +--- +>>>export { helper as helperBare } from "./helper"; +1 > +2 >^^^^^^^ +3 > ^^ +4 > ^^^^^^ +5 > ^^^^ +6 > ^^^^^^^^^^ +7 > ^^ +8 > ^^^^^^ +9 > ^^^^^^^^^^ +10> ^ +1 > + > +2 >export +3 > { +4 > helper +5 > as +6 > helperBare +7 > } +8 > from +9 > "./helper" +10> ; +1 >Emitted(7, 1) Source(7, 1) + SourceIndex(0) +2 >Emitted(7, 8) Source(7, 8) + SourceIndex(0) +3 >Emitted(7, 10) Source(7, 10) + SourceIndex(0) +4 >Emitted(7, 16) Source(7, 16) + SourceIndex(0) +5 >Emitted(7, 20) Source(7, 20) + SourceIndex(0) +6 >Emitted(7, 30) Source(7, 30) + SourceIndex(0) +7 >Emitted(7, 32) Source(7, 32) + SourceIndex(0) +8 >Emitted(7, 38) Source(7, 38) + SourceIndex(0) +9 >Emitted(7, 48) Source(7, 48) + SourceIndex(0) +10>Emitted(7, 49) Source(7, 49) + SourceIndex(0) +--- +>>>//# sourceMappingURL=main.d.ts.map \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/outputExtension.symbols b/tsc/testdata/baselines/reference/compiler/outputExtension.symbols new file mode 100644 index 0000000000000..7e13e0f00bcf6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtension.symbols @@ -0,0 +1,63 @@ +//// [tests/cases/compiler/outputExtension.ts] //// + +=== /helper.ts === +export declare const helper: string; +>helper : Symbol(helper, Decl(helper.ts, 0, 20)) + +=== /other.p === +const __VERSION = "1.0.0"; +>__VERSION : Symbol(__VERSION, Decl(other.p, 0, 5)) + +export declare const other: number; +>other : Symbol(other, Decl(other.p, 1, 20)) + +=== /component.y.z === +const __VERSION = "1.0.0"; +>__VERSION : Symbol(__VERSION, Decl(component.y.z, 0, 5)) + +import { helper } from "./helper.ts"; +>helper : Symbol(helper, Decl(component.y.z, 1, 8)) + +import { other } from "./other.p"; +>other : Symbol(other, Decl(component.y.z, 2, 8)) + +export interface ComponentProps { +>ComponentProps : Symbol(ComponentProps, Decl(component.y.z, 2, 34)) + + label: typeof helper; +>label : Symbol(ComponentProps.label, Decl(component.y.z, 3, 33)) +>helper : Symbol(helper, Decl(component.y.z, 1, 8)) + + count: typeof other; +>count : Symbol(ComponentProps.count, Decl(component.y.z, 4, 25)) +>other : Symbol(other, Decl(component.y.z, 2, 8)) +} +export declare const component: ComponentProps; +>component : Symbol(component, Decl(component.y.z, 7, 20)) +>ComponentProps : Symbol(ComponentProps, Decl(component.y.z, 2, 34)) + +=== /main.ts === +export { component } from "./component.y.z"; +>component : Symbol(component, Decl(main.ts, 0, 8)) + +export type { ComponentProps } from "./component.y.z"; +>ComponentProps : Symbol(ComponentProps, Decl(main.ts, 1, 13)) + +export type Props = import("./component.y.z").ComponentProps; +>Props : Symbol(Props, Decl(main.ts, 1, 54)) +>ComponentProps : Symbol(ComponentProps, Decl(component.y.z, 2, 34)) + +export * as other from "./other.p"; +>other : Symbol(other, Decl(main.ts, 3, 6)) + +export { helper } from "./helper.ts"; +>helper : Symbol(helper, Decl(main.ts, 4, 8)) + +export { helper as helperJs } from "./helper.js"; +>helper : Symbol(helper, Decl(helper.ts, 0, 20)) +>helperJs : Symbol(helperJs, Decl(main.ts, 5, 8)) + +export { helper as helperBare } from "./helper"; +>helper : Symbol(helper, Decl(helper.ts, 0, 20)) +>helperBare : Symbol(helperBare, Decl(main.ts, 6, 8)) + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtension.types b/tsc/testdata/baselines/reference/compiler/outputExtension.types new file mode 100644 index 0000000000000..b58fd30bd4fc0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtension.types @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/outputExtension.ts] //// + +=== /helper.ts === +export declare const helper: string; +>helper : string + +=== /other.p === +const __VERSION = "1.0.0"; +>__VERSION : "1.0.0" +>"1.0.0" : "1.0.0" + +export declare const other: number; +>other : number + +=== /component.y.z === +const __VERSION = "1.0.0"; +>__VERSION : "1.0.0" +>"1.0.0" : "1.0.0" + +import { helper } from "./helper.ts"; +>helper : string + +import { other } from "./other.p"; +>other : number + +export interface ComponentProps { + label: typeof helper; +>label : string +>helper : string + + count: typeof other; +>count : number +>other : number +} +export declare const component: ComponentProps; +>component : ComponentProps + +=== /main.ts === +export { component } from "./component.y.z"; +>component : import("./component.y.z").ComponentProps + +export type { ComponentProps } from "./component.y.z"; +>ComponentProps : import("./component.y.z").ComponentProps + +export type Props = import("./component.y.z").ComponentProps; +>Props : import("./component.y.z").ComponentProps + +export * as other from "./other.p"; +>other : typeof import("./other.p") + +export { helper } from "./helper.ts"; +>helper : string + +export { helper as helperJs } from "./helper.js"; +>helper : string +>helperJs : string + +export { helper as helperBare } from "./helper"; +>helper : string +>helperBare : string + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.contentmapper b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.contentmapper new file mode 100644 index 0000000000000..d898244e57510 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.contentmapper @@ -0,0 +1,10 @@ +//// [/app.y.z] (ScriptKind: ScriptKindTS, ContentMapper: [.y.z]) +--- Original --- +export declare const mapped: string; +--- Transformed --- +const __VERSION = "1.0.0"; +export declare const mapped: string; + +=== Diagnostics === + + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.errors.txt b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.errors.txt new file mode 100644 index 0000000000000..bc058aad13e3b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.errors.txt @@ -0,0 +1,32 @@ +error TS5056: Cannot write file '/app.d.ts' because it would be overwritten by multiple input files. + + +!!! error TS5056: Cannot write file '/app.d.ts' because it would be overwritten by multiple input files. +==== /tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "declaration": true, + "emitDeclarationOnly": true, + "outputExtension": ".js" + }, + "contentMappers": [ + { "package": "mapper", "extensions": [".y.z"] } + ] + } + +==== /app.ts (0 errors) ==== + export declare const source: string; + +==== /main.ts (0 errors) ==== + export { mapped } from "./app.y.z"; + export { source } from "./app"; + +==== /node_modules/mapper/package.json (0 errors) ==== + { + "name": "mapper", + "version": "1.0.0", + "typescript": { "contentMapper": { "exec": ["compiler-test-mapper"] } } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.js b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.js new file mode 100644 index 0000000000000..3463d0aa2253d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/outputExtensionConflict.ts] //// + +//// [package.json] +{ + "name": "mapper", + "version": "1.0.0", + "typescript": { "contentMapper": { "exec": ["compiler-test-mapper"] } } +} + +//// [app.y.z] +const __VERSION = "1.0.0"; +export declare const mapped: string; + +//// [app.ts] +export declare const source: string; + +//// [main.ts] +export { mapped } from "./app.y.z"; +export { source } from "./app"; + + + + +//// [main.d.ts] +export { mapped } from "./app.js"; +export { source } from "./app"; diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.symbols b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.symbols new file mode 100644 index 0000000000000..98a5ab2acb6c9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/outputExtensionConflict.ts] //// + +=== /app.y.z === +const __VERSION = "1.0.0"; +>__VERSION : Symbol(__VERSION, Decl(app.y.z, 0, 5)) + +export declare const mapped: string; +>mapped : Symbol(mapped, Decl(app.y.z, 1, 20)) + +=== /app.ts === +export declare const source: string; +>source : Symbol(source, Decl(app.ts, 0, 20)) + +=== /main.ts === +export { mapped } from "./app.y.z"; +>mapped : Symbol(mapped, Decl(main.ts, 0, 8)) + +export { source } from "./app"; +>source : Symbol(source, Decl(main.ts, 1, 8)) + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.types b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.types new file mode 100644 index 0000000000000..28c98310d364c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionConflict.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/outputExtensionConflict.ts] //// + +=== /app.y.z === +const __VERSION = "1.0.0"; +>__VERSION : "1.0.0" +>"1.0.0" : "1.0.0" + +export declare const mapped: string; +>mapped : string + +=== /app.ts === +export declare const source: string; +>source : string + +=== /main.ts === +export { mapped } from "./app.y.z"; +>mapped : string + +export { source } from "./app"; +>source : string + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.errors.txt b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.errors.txt new file mode 100644 index 0000000000000..a65272bde01d5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.errors.txt @@ -0,0 +1,17 @@ +/tsconfig.json(5,28): error TS6046: Argument for '--outputExtension' option must be: '.js', '.mjs', '.cjs'. + + +==== /tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outputExtension": ".jsx" + ~~~~~~ +!!! error TS6046: Argument for '--outputExtension' option must be: '.js', '.mjs', '.cjs'. + } + } + +==== /main.ts (0 errors) ==== + export declare const main: string; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.js b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.js new file mode 100644 index 0000000000000..a3fc5c24a5f2a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/outputExtensionInvalidValue.ts] //// + +//// [main.ts] +export declare const main: string; + + + + +//// [main.d.ts] +export declare const main: string; diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.symbols b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.symbols new file mode 100644 index 0000000000000..c6e5f1f8906e3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/outputExtensionInvalidValue.ts] //// + +=== /main.ts === +export declare const main: string; +>main : Symbol(main, Decl(main.ts, 0, 20)) + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.types b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.types new file mode 100644 index 0000000000000..3c340061aea78 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionInvalidValue.types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/outputExtensionInvalidValue.ts] //// + +=== /main.ts === +export declare const main: string; +>main : string + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.js b/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.js new file mode 100644 index 0000000000000..04199163f772d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/outputExtensionMjs.ts] //// + +//// [a.ts] +export declare const a: string; + +//// [b.tsx] +export declare const b: number; + +//// [main.ts] +export { a } from "./a.ts"; +export { b } from "./b.tsx"; +export type A = typeof import("./a.ts").a; + + + + +//// [a.d.mts] +export declare const a: string; +//// [b.d.mts] +export declare const b: number; +//// [main.d.mts] +export { a } from "./a.mjs"; +export { b } from "./b.mjs"; +export type A = typeof import("./a.mjs").a; diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.symbols b/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.symbols new file mode 100644 index 0000000000000..c5aeb4bd90f46 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/outputExtensionMjs.ts] //// + +=== /a.ts === +export declare const a: string; +>a : Symbol(a, Decl(a.ts, 0, 20)) + +=== /b.tsx === +export declare const b: number; +>b : Symbol(b, Decl(b.tsx, 0, 20)) + +=== /main.ts === +export { a } from "./a.ts"; +>a : Symbol(a, Decl(main.ts, 0, 8)) + +export { b } from "./b.tsx"; +>b : Symbol(b, Decl(main.ts, 1, 8)) + +export type A = typeof import("./a.ts").a; +>A : Symbol(A, Decl(main.ts, 1, 28)) +>a : Symbol(a, Decl(a.ts, 0, 20)) + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.types b/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.types new file mode 100644 index 0000000000000..f6ba0d479b5b5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionMjs.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/outputExtensionMjs.ts] //// + +=== /a.ts === +export declare const a: string; +>a : string + +=== /b.tsx === +export declare const b: number; +>b : number + +=== /main.ts === +export { a } from "./a.ts"; +>a : string + +export { b } from "./b.tsx"; +>b : number + +export type A = typeof import("./a.ts").a; +>A : string +>a : error + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.errors.txt b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.errors.txt new file mode 100644 index 0000000000000..b60dc5e12b5eb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.errors.txt @@ -0,0 +1,16 @@ +/tsconfig.json(4,9): error TS5069: Option 'outputExtension' cannot be specified without specifying option 'noEmit' or option 'emitDeclarationOnly'. + + +==== /tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "declaration": true, + "outputExtension": ".js" + ~~~~~~~~~~~~~~~~~ +!!! error TS5069: Option 'outputExtension' cannot be specified without specifying option 'noEmit' or option 'emitDeclarationOnly'. + } + } + +==== /main.ts (0 errors) ==== + export declare const main: string; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.js b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.js new file mode 100644 index 0000000000000..628fc19c55b32 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/outputExtensionRequiresEmitDeclarationOnly.ts] //// + +//// [main.ts] +export declare const main: string; + + +//// [main.js] +export {}; + + +//// [main.d.ts] +export declare const main: string; diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.symbols b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.symbols new file mode 100644 index 0000000000000..8317fb46a5dac --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/outputExtensionRequiresEmitDeclarationOnly.ts] //// + +=== /main.ts === +export declare const main: string; +>main : Symbol(main, Decl(main.ts, 0, 20)) + diff --git a/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.types b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.types new file mode 100644 index 0000000000000..d2ad3a70c6b01 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/outputExtensionRequiresEmitDeclarationOnly.types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/outputExtensionRequiresEmitDeclarationOnly.ts] //// + +=== /main.ts === +export declare const main: string; +>main : string + diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js b/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js index db9dd22705973..c5e0b76e4bac7 100644 --- a/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js +++ b/tsc/testdata/baselines/reference/tsc/commandLine/help-all.js @@ -431,6 +431,11 @@ Specify an output folder for all emitted files. --outFile Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. +--outputExtension +Specify the file extension that an external build gives every source file, so that declaration file names and their relative imports match the build output. +one of: .js, .mjs, .cjs +default: undefined + --preserveConstEnums Disable erasing 'const enum' declarations in generated code. type: boolean diff --git a/tsc/testdata/tests/cases/compiler/outputExtension.ts b/tsc/testdata/tests/cases/compiler/outputExtension.ts new file mode 100644 index 0000000000000..c1950741626d4 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/outputExtension.ts @@ -0,0 +1,49 @@ +// @runExternalCode: true + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "target": "es2020", + "module": "esnext", + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outputExtension": ".js" + }, + "contentMappers": [ + { "package": "mapper", "extensions": [".y.z", ".p"] } + ] +} + +// @Filename: /node_modules/mapper/package.json +{ + "name": "mapper", + "version": "1.0.0", + "typescript": { "contentMapper": { "exec": ["compiler-test-mapper"] } } +} + +// @Filename: /helper.ts +export declare const helper: string; + +// @Filename: /other.p +export declare const other: number; + +// @Filename: /component.y.z +import { helper } from "./helper.ts"; +import { other } from "./other.p"; +export interface ComponentProps { + label: typeof helper; + count: typeof other; +} +export declare const component: ComponentProps; + +// @Filename: /main.ts +export { component } from "./component.y.z"; +export type { ComponentProps } from "./component.y.z"; +export type Props = import("./component.y.z").ComponentProps; +export * as other from "./other.p"; +export { helper } from "./helper.ts"; +export { helper as helperJs } from "./helper.js"; +export { helper as helperBare } from "./helper"; diff --git a/tsc/testdata/tests/cases/compiler/outputExtensionConflict.ts b/tsc/testdata/tests/cases/compiler/outputExtensionConflict.ts new file mode 100644 index 0000000000000..73dde7dfb0505 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/outputExtensionConflict.ts @@ -0,0 +1,32 @@ +// @runExternalCode: true + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "declaration": true, + "emitDeclarationOnly": true, + "outputExtension": ".js" + }, + "contentMappers": [ + { "package": "mapper", "extensions": [".y.z"] } + ] +} + +// @Filename: /node_modules/mapper/package.json +{ + "name": "mapper", + "version": "1.0.0", + "typescript": { "contentMapper": { "exec": ["compiler-test-mapper"] } } +} + +// @Filename: /app.y.z +export declare const mapped: string; + +// @Filename: /app.ts +export declare const source: string; + +// @Filename: /main.ts +export { mapped } from "./app.y.z"; +export { source } from "./app"; diff --git a/tsc/testdata/tests/cases/compiler/outputExtensionInvalidValue.ts b/tsc/testdata/tests/cases/compiler/outputExtensionInvalidValue.ts new file mode 100644 index 0000000000000..dd62091069f23 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/outputExtensionInvalidValue.ts @@ -0,0 +1,11 @@ +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outputExtension": ".jsx" + } +} + +// @Filename: /main.ts +export declare const main: string; diff --git a/tsc/testdata/tests/cases/compiler/outputExtensionMjs.ts b/tsc/testdata/tests/cases/compiler/outputExtensionMjs.ts new file mode 100644 index 0000000000000..c3a41bee309bd --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/outputExtensionMjs.ts @@ -0,0 +1,23 @@ +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "module": "esnext", + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "jsx": "preserve", + "declaration": true, + "emitDeclarationOnly": true, + "outputExtension": ".mjs" + } +} + +// @Filename: /a.ts +export declare const a: string; + +// @Filename: /b.tsx +export declare const b: number; + +// @Filename: /main.ts +export { a } from "./a.ts"; +export { b } from "./b.tsx"; +export type A = typeof import("./a.ts").a; diff --git a/tsc/testdata/tests/cases/compiler/outputExtensionRequiresEmitDeclarationOnly.ts b/tsc/testdata/tests/cases/compiler/outputExtensionRequiresEmitDeclarationOnly.ts new file mode 100644 index 0000000000000..76faab99f3ffb --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/outputExtensionRequiresEmitDeclarationOnly.ts @@ -0,0 +1,10 @@ +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "declaration": true, + "outputExtension": ".js" + } +} + +// @Filename: /main.ts +export declare const main: string;