Skip to content

TypeScript removes comments even when removeComments: falseΒ #47158

@abelepereira

Description

@abelepereira

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}]]*/ {};

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions