Skip to content

Conversation

@MichaelMitchell-at
Copy link
Contributor

Fixes #59313

Copy link
Contributor Author

@MichaelMitchell-at MichaelMitchell-at left a comment

Choose a reason for hiding this comment

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

I've verified this fixes the issue for my use case, but I'm not sure how to write a test for this. I didn't find any existing tests that I could use as a reference.

cc @weswigham

affectsBuildInfo: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Emit,
transpileOptionValue: undefined,
Copy link
Contributor 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;
}

}
// 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
Contributor 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
Contributor 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.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 17, 2024
@sheetalkamat
Copy link
Member

Closing in favor of #59337

@MichaelMitchell-at MichaelMitchell-at deleted the fix_transpile_declaration_source_map branch July 18, 2024 18:53
@sandersn sandersn removed this from PR Backlog Apr 22, 2025
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[transpileDeclaration API] ts.transpileDeclaration always returns empty sourceMapText

3 participants