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

Do not remove PURE comment after typed declaration #32060

Closed
LongTengDao opened this issue Jun 24, 2019 · 7 comments
Closed

Do not remove PURE comment after typed declaration #32060

LongTengDao opened this issue Jun 24, 2019 · 7 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@LongTengDao
Copy link
Contributor

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms:

Code

const a :Type = /*#__PURE__*/ function () {}();

Expected behavior:

const a = /*#__PURE__*/ function () {}();

Actual behavior:

const a = function () {}();

Playground Link:

Related Issues:

@AnyhowStep
Copy link
Contributor

AnyhowStep commented Jun 24, 2019

Why not make it a JSDoc?

/**
 * __PURE__
 */
const a : Type = function () {}();

Output:

/**
 * __PURE__
 */
var a = function () { }();

@AlCalzone
Copy link
Contributor

This is #13721 I think

@LongTengDao
Copy link
Contributor Author

@AnyhowStep Thanks for reply. I didn't know that. But only /*#__PURE__*/ is widely used in downstream tools, like rollup (pack tool) or uglify/terser (minify tool).

BTW: I wonder why the comment removed, it's just same line with types syntax, not same part of an expression, even not same side of assignment equal mark...

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jun 26, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jun 26, 2019
@ashi009
Copy link

ashi009 commented Sep 17, 2019

@AlCalzone

This is #13721 I think

#13721 is mainly for classes, which is fixed in #16631. This is actually #7770.

@LongTengDao

A workaround is to add parentheses around the pure expression, which will preserve the comment until this is fixed.

const a : Type = (/*#__PURE__*/ function () {}());
// var a = ( /*#__PURE__*/function () { }());

@LongTengDao
Copy link
Contributor Author

@ashi009 Oh, that works, thank you!

Anyway, I wrote my personal ts transpiler (@ ltd/j-ts) ;)

@LongTengDao
Copy link
Contributor Author

seems fixed in 5.3

@jakebailey
Copy link
Member

Yes, this was fixed by #47407 (and #47158 was a dupe of this one).

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

No branches or pull requests

6 participants