Bug Report
π Search Terms
comments, removeComments, implicit semicolon
π Version & Regression Information
I first noticed this in version 4.2.4. I have not tried earlier versions. It is still happening as of 4.3.5.
β― Playground Link
https://www.typescriptlang.org/play?target=1#code/FAYw9gdgzgLgBAMzGOBeOBGADFg3MUSWOAcwFMYAJMgSxIAt50AKASjQD5g44ADAEgDe3HnAD0YuAEE4AGzIQSMegE844ALYaFMETyRgRAXwAOAD164gA
π» Code
When removeComments: false and target: es5, the following code:
const foo = 100;
const getHeight = () =>
`${
// A lengthy comment
foo
}px`;
generates this output
"use strict";
var foo = 100;
var getHeight = function () {
return
// A lengthy comment
foo + "px";
};
π Actual behavior
The outputted code is incorrect due to the 'implicit semicolon' immediately after the return. Instead of returning "100px" the generated getHeight function returns undefined and the foo + "px"; statement is unreachable code.
π Expected behavior
I would instead expect the output to be more like this (note additional parentheses).
"use strict";
var foo = 100;
var getHeight = function () {
return (
// A lengthy comment
foo + "px");
};
Bug Report
π Search Terms
comments, removeComments, implicit semicolon
π Version & Regression Information
I first noticed this in version 4.2.4. I have not tried earlier versions. It is still happening as of 4.3.5.
β― Playground Link
https://www.typescriptlang.org/play?target=1#code/FAYw9gdgzgLgBAMzGOBeOBGADFg3MUSWOAcwFMYAJMgSxIAt50AKASjQD5g44ADAEgDe3HnAD0YuAEE4AGzIQSMegE844ALYaFMETyRgRAXwAOAD164gA
π» Code
When
removeComments: falseandtarget: es5, the following code:generates this output
π Actual behavior
The outputted code is incorrect due to the 'implicit semicolon' immediately after the
return. Instead of returning"100px"the generatedgetHeightfunction returnsundefinedand thefoo + "px";statement is unreachable code.π Expected behavior
I would instead expect the output to be more like this (note additional parentheses).