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

TypeScript removes comments even when removeComments: false #47158

Closed
abelepereira opened this issue Dec 15, 2021 · 3 comments Β· Fixed by #47407
Closed

TypeScript removes comments even when removeComments: false #47158

abelepereira opened this issue Dec 15, 2021 · 3 comments Β· Fixed by #47407
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@abelepereira
Copy link

Bug Report

TypeScript removes comments when transpiling even when removeComments: false.

πŸ”Ž Search Terms

removeComments; comments;

πŸ•— Version & Regression Information

Seems to happen on all versions (at least from 3.x to latest).

⏯ Playground Link

Playground Link

πŸ’» Code

Specifying a type on b causes the problem to manifest,

let a = /*[[${something}]]*/ {};
let b: any = /*[[${something}]]*/ {};

πŸ™ Actual behavior

Produces the following output when removeComments is set to false on tsconfig.json:

"use strict";
let a = /*[[${something}]]*/ {};
let b = {};

πŸ™‚ Expected behavior

Should keep the comments on both lines:

"use strict";
let a = /*[[${something}]]*/ {};
let b = /*[[${something}]]*/ {};
@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Dec 15, 2021
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 15, 2021
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Dec 15, 2021
@RyanCavanaugh
Copy link
Member

Just to set expectations, removeComments: false is not a guarantee that 100% of comments will be retained -- those attached to interfaces, for example, will still not be present in the JS.

This case looks like an oversight though

@a-tarasyuk
Copy link
Contributor

It looks similar to #40943

@abelepereira
Copy link
Author

yup, it's a dup of #40943.

@RyanCavanaugh for interfaces and other type artifacts that are lost while transpiling, it's fine. And I would say, it's even expected those to be lost.

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

Successfully merging a pull request may close this issue.

3 participants