mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-15 03:09:59 -05:00
Allow declarationMap to be emitted when transpiling declarations and option is enabled (#59337)
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
computeSignatureWithDiagnostics,
|
||||
CustomTransformers,
|
||||
Debug,
|
||||
EmitOnly,
|
||||
EmitOutput,
|
||||
emptyArray,
|
||||
GetCanonicalFileName,
|
||||
@@ -418,7 +419,7 @@ export namespace BuilderState {
|
||||
);
|
||||
},
|
||||
cancellationToken,
|
||||
/*emitOnly*/ true,
|
||||
EmitOnly.BuilderSignature,
|
||||
/*customTransformers*/ undefined,
|
||||
/*forceDtsEmit*/ true,
|
||||
);
|
||||
|
||||
@@ -467,7 +467,6 @@ export const commonOptionsWithBuild: CommandLineOption[] = [
|
||||
affectsBuildInfo: true,
|
||||
showInSimplifiedHelpView: true,
|
||||
category: Diagnostics.Emit,
|
||||
transpileOptionValue: undefined,
|
||||
defaultValueDescription: false,
|
||||
description: Diagnostics.Create_sourcemaps_for_d_ts_files,
|
||||
},
|
||||
|
||||
@@ -907,7 +907,7 @@ export function emitFiles(
|
||||
module: compilerOptions.module,
|
||||
moduleResolution: compilerOptions.moduleResolution,
|
||||
target: compilerOptions.target,
|
||||
sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
|
||||
sourceMap: emitOnly !== EmitOnly.BuilderSignature && compilerOptions.declarationMap,
|
||||
inlineSourceMap: compilerOptions.inlineSourceMap,
|
||||
extendedDiagnostics: compilerOptions.extendedDiagnostics,
|
||||
onlyPrintJsDocStyle: true,
|
||||
|
||||
@@ -4648,6 +4648,7 @@ export type FilePreprocessingDiagnostics = FilePreprocessingLibReferenceDiagnost
|
||||
export const enum EmitOnly {
|
||||
Js,
|
||||
Dts,
|
||||
BuilderSignature,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -48,7 +48,11 @@ enum TranspileKind {
|
||||
}
|
||||
|
||||
class TranspileTestCase {
|
||||
static varyBy = [];
|
||||
static varyBy = [
|
||||
"declarationMap",
|
||||
"sourceMap",
|
||||
"inlineSourceMap",
|
||||
];
|
||||
|
||||
static getConfigurations(file: string): TranspileTestCase[] {
|
||||
const ext = vpath.extname(file);
|
||||
@@ -104,6 +108,13 @@ class TranspileTestCase {
|
||||
if (!result.outputText.endsWith("\n")) {
|
||||
baselineText += "\r\n";
|
||||
}
|
||||
if (result.sourceMapText) {
|
||||
baselineText += `//// [${ts.changeExtension(unit.name, kind === TranspileKind.Module ? this.getJsOutputExtension(unit.name) : ts.getDeclarationEmitExtensionForPath(unit.name))}.map] ////\r\n`;
|
||||
baselineText += result.sourceMapText;
|
||||
if (!result.outputText.endsWith("\n")) {
|
||||
baselineText += "\r\n";
|
||||
}
|
||||
}
|
||||
if (result.diagnostics && result.diagnostics.length) {
|
||||
baselineText += "\r\n\r\n//// [Diagnostics reported]\r\n";
|
||||
baselineText += Compiler.getErrorBaseline([{ content: unit.content, unitName: unit.name }], result.diagnostics, !!opts.pretty);
|
||||
|
||||
Reference in New Issue
Block a user