Skip to content

[transpileDeclaration API] ts.transpileDeclaration always returns empty sourceMapTextΒ #59313

@MichaelMitchell-at

Description

@MichaelMitchell-at

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions