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

transpileModule should set declarationMap = undefined when it sets declaration = undefined #31991

Closed
cspotcode opened this issue Jun 20, 2019 · 5 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@cspotcode
Copy link

transpileModule unsets the declaration compilerOption but not the declarationMap option. This causes an error diagnostic to be emitted when the compilerOptions passed to transpileModule have both of those options set to true. This can happen, for example, when using a tool that automatically loads a tsconfig and passes it to transpileModule. The reproduction link shows the exact diagnostic message.

I think the fix needs to happen at this line of code:
https://github.com/microsoft/TypeScript/blob/master/src/services/transpile.ts#L50

It needs to be followed by options.declarationMap = undefined;

Specifically, this was happening to me when using webpack's ts-loader. I have my tsconfig setup with declaration: true and declarationMap: true but ts-loader configured to transpileOnly, meaning it internally calls transpileModule.

TypeScript Version: 3.6.0-dev.20190619

Search Terms:

transpileModule declarationMap

Code

require('typescript').transpileModule('const foo = 1;', {compilerOptions: {declaration: true, declarationMap: true}, reportDiagnostics: true})

Expected behavior:

Zero diagnostics returned.

Actual behavior:

This diagnostic is returned:

Option 'declarationMap' cannot be specified without specifying option 'declaration' or option 'composite'.

Playground Link:

Instead I made a repl.it demonstration:
https://repl.it/@AndrewBradley/FavorableBlushingSale

Related Issues:

@eduardoflorendo

This comment has been minimized.

@eduardoflorendo

This comment has been minimized.

@eduardoflorendo

This comment has been minimized.

@eduardoflorendo

This comment has been minimized.

@RyanCavanaugh RyanCavanaugh self-assigned this Jun 25, 2019
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jun 25, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 25, 2019
@RyanCavanaugh RyanCavanaugh removed their assignment Jun 25, 2019
@jakebailey
Copy link
Member

This was fixed by #59642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants