Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ts.transpileDeclaration having empty sourceMapText when declarationMap is true #59314

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ export const commonOptionsWithBuild: CommandLineOption[] = [
affectsBuildInfo: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Emit,
transpileOptionValue: undefined,
Copy link
Author

@MichaelMitchell-at MichaelMitchell-at Jul 17, 2024

Choose a reason for hiding this comment

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

This being set to undefined caused declarationMap to be set to undefined in options

for (const option of transpileOptionValueCompilerOptions) {
// Do not set redundant config options if `verbatimModuleSyntax` was supplied.
if (options.verbatimModuleSyntax && optionsRedundantWithVerbatimModuleSyntax.has(option.name)) {
continue;
}
options[option.name] = option.transpileOptionValue;
}

defaultValueDescription: false,
description: Diagnostics.Create_sourcemaps_for_d_ts_files,
},
Expand Down
2 changes: 1 addition & 1 deletion src/services/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function transpileWorker(input: string, transpileOptions: TranspileOptions, decl
addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics());
}
// Emit
const result = program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ declaration, transpileOptions.transformers, /*forceDtsEmit*/ declaration);
const result = program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnly*/ undefined, transpileOptions.transformers, /*forceDtsEmit*/ undefined);
Copy link
Author

@MichaelMitchell-at MichaelMitchell-at Jul 17, 2024

Choose a reason for hiding this comment

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

Before we were passing true to forceDtsEmit, which caused this to evaluate to false:

sourceMap: !forceDtsEmit && compilerOptions.declarationMap,

though I'm not sure if this is actually the correct fix. Perhaps it would be to just remove !forceDtsEmit && from emitter.ts.

Changing emitOnlyDtsFiles to undefined actually doesn't seem to matter, at least with the configuration I tested with, which seems kind of surprising.

Copy link
Author

Choose a reason for hiding this comment

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

Well, no permutation of what I said results in all the tests passing, so clearly not as easy of a fix as I hoped.


addRange(/*to*/ diagnostics, /*from*/ result.diagnostics);

Expand Down
Loading