[transpileDeclaration API] ts.transpileDeclaration always returns empty sourceMapText

🔎 Search Terms

transpileDeclaration source map declarationmap

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

No response

💻 Code

const {config} = ts.readConfigFile(project, ts.sys.readFile);

const basePath = path.resolve(path.dirname(project));

const {
    options,
    fileNames: rootNames,
} = ts.parseJsonConfigFileContent(config, ts.sys, basePath);

const program = ts.createProgram({
    rootNames,
    options,
    host: ts.createCompilerHost(options),
});

const sourceFiles = program.getSourceFiles();

for (const sourceFile of sourceFiles) {
    const declarationFile = ts.transpileDeclaration(sourceFile.text, {
        compilerOptions: options,
        fileName: sourceFile.fileName,
    });

    console.log(declarationFile.sourceMapText);
}

🙁 Actual behavior

If the TSConfig contains "declarationMap": true, sourceFileText is undefined.

🙂 Expected behavior

If the TSConfig contains "declarationMap": true, sourceFileText contains the declaration source map.

Additional information about the issue

No response