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

TSC remove comments even when removeComments to false #16727

Closed
AlgusDark opened this issue Jun 24, 2017 · 8 comments
Closed

TSC remove comments even when removeComments to false #16727

AlgusDark opened this issue Jun 24, 2017 · 8 comments
Labels
Duplicate An existing issue was already created

Comments

@AlgusDark
Copy link

TypeScript Version: 2.4.0

Code

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

Expected behavior:

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

Actual behavior:

var a = (function () { })();

If I wrote the comment above the declaration, it works, but I need that comment because is going to help me with Uglify to know that this is a pure function with no side-effects.

@kitsonk
Copy link
Contributor

kitsonk commented Jun 24, 2017

You mean does remove comments, correct?

The compiler does seem to erase comments in some surprising ways.

@kitsonk
Copy link
Contributor

kitsonk commented Jun 24, 2017

This sort of seem related to #1665 in that the compiler will erase comments where it thinks the comment is related to some code it is not emitting, but obviously it is getting a but over active in some positions.

@AlgusDark AlgusDark changed the title TSC doesn't remove comments even when removeComments to false TSC does remove comments even when removeComments to false Jun 24, 2017
@AlgusDark
Copy link
Author

You're right, I edited my question. It's erasing the comments as you mention.

Ohh, I was afraid it was a bug, thanks for pointing that issue.

@AlgusDark AlgusDark changed the title TSC does remove comments even when removeComments to false TSC remove comments even when removeComments to false Jun 24, 2017
@nishantkagrawal
Copy link

nishantkagrawal commented Jul 11, 2017

As per #3844 using /*! should work. But it doesn't work either.

this.form['additionalName'].customValidationMessage = /*! i18nextract */ 'Some message';

while if the comment is moved to another line, it works.

this.form['additionalName'].customValidationMessage =
                /*! i18nextract */ 'Some message';

As per @yuit it was fixed, but it seems it is not fixed for all cases.

I am using typescript 2.3.4

@mhegazy
Copy link
Contributor

mhegazy commented Aug 24, 2017

looks like a duplicate of #17606

@mhegazy mhegazy added the Duplicate An existing issue was already created label Aug 24, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 7, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 7, 2017
@benjamin21st
Copy link

I think I found one of the "mysterious ways" TSC would ignore the removeComments: false, see this example:
http://www.typescriptlang.org/play/#src=let%20stuff%20%3D%20%5B%0A%20%20%20%201%2C%0A%20%20%20%202%2C%0A%20%20%20%20%2F%2F%203%2C%0A%20%20%20%20%2F%2F%204%0A%5D

In case the link expires, here is the code:

let stuff = [
    1,
    2,
    // 3,
    // 4
]

The commented out lines 3 and 4 will be removed. But if one removes the trailing comma next to 2, the two lines will be preserved.

Not sure if this is a feature or bug -__-

@codemilli
Copy link

For React with typescript user, adding 'removeComments': false to ts-loader options is working rather than adding 'removeComments': false to tsconfig.json.

@microsoft microsoft locked and limited conversation to collaborators Jul 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

6 participants