You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When removeComments: false and target: es5, the following code:
constfoo=100;constgetHeight=()=>`${// A lengthy commentfoo}px`;
generates this output
"use strict";varfoo=100;vargetHeight=function(){return// A lengthy commentfoo+"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";varfoo=100;vargetHeight=function(){return(// A lengthy commentfoo+"px");};
The text was updated successfully, but these errors were encountered:
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
andtarget: 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 generatedgetHeight
function returnsundefined
and thefoo + "px";
statement is unreachable code.π Expected behavior
I would instead expect the output to be more like this (note additional parentheses).
The text was updated successfully, but these errors were encountered: