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
The magic of Recast is that it reprints only those parts of the syntax tree that you modify. In other words, the following identity is guaranteed: recast.print(recast.parse(source)).code === source
However, it does not hold true in a specific scenario: when there are comments nested within JSX elements.
Behaviour
Consider the following code as input:
exportconstTable=()=>{return(<ListclassName={styles.topMargin}><Rows>{alerts.map(alert=>(// This is a comment<Alertid={alert}/>))}</Rows></List>);}
One would expect the output to be the exact same as the input, as the AST is untouched. However, extra parenthesis are added to some of the JSX elements:
I wrote an AST Explorer example to reproduce the issue. Please note that the AST is not properly printed there due to the lack of proper support for customising parsers in the visualisation for Recast in AST Explorer, but the transformation applies properly, although it generates improper code.
The text was updated successfully, but these errors were encountered:
Overview
Recast's documentation states the following:
However, it does not hold true in a specific scenario: when there are comments nested within JSX elements.
Behaviour
Consider the following code as input:
And the following configuration:
One would expect the output to be the exact same as the input, as the AST is untouched. However, extra parenthesis are added to some of the JSX elements:
I wrote an AST Explorer example to reproduce the issue. Please note that the AST is not properly printed there due to the lack of proper support for customising parsers in the visualisation for Recast in AST Explorer, but the transformation applies properly, although it generates improper code.
The text was updated successfully, but these errors were encountered: