Call expression's leading comments are removed when assigned to a explicitly typed variable #40943
Labels
Bug
A bug in TypeScript
Domain: Comment Emit
The issue relates to the emission of comments when compiling
Fix Available
A PR has been opened for this issue
Rescheduled
This issue was previously scheduled to an earlier milestone
Milestone
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, soterser
anduglify
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
Expected behavior:
Actual behavior:
Playground Link: https://www.typescriptlang.org/play?ts=4.1.0-dev.20201005#code/MYewdgzgLgBAbgQwE4EYYF4YHoBUNQC2BApmFGjljAGYggAUARsgJQDcAUKJLIkgEwAuGAjABPDNjyESZfjEo06TVpyA
Related Issues: #17606 #16727
The text was updated successfully, but these errors were encountered: