-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Comment EmitThe issue relates to the emission of comments when compilingThe issue relates to the emission of comments when compilingFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
The leading comment of a call expression should be kept when removeComments: false
. And indeed, it is kept in the majority of cases, except when it is in an assignment statement that also has an explicit type annotation.
My use case for this is to keep /** @__PURE__ */
annotations in some assignments that are side-effect free, so terser
and uglify
can remove them if unused.
There are some similar issues here already but they are closed and I suspect this is an edge case that was not accounted for.
TypeScript Version: 4.1.0-dev.20201005
Search Terms: comments, pure, annotation, uglify
Code
const var1 = /* comment1 */ foo(bar);
const var2: any = /* comment2 */ foo(bar);
Expected behavior:
const var1 = /* comment1 */ foo(bar);
const var2 = /* comment2 */ foo(bar);
Actual behavior:
const var1 = /* comment1 */ foo(bar);
const var2 = foo(bar);
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Comment EmitThe issue relates to the emission of comments when compilingThe issue relates to the emission of comments when compilingFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone