Closed
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);