syntax icon indicating copy to clipboard operation
syntax copied to clipboard

JSX preserve mode with `@JSX` attribute

Open mununki opened this issue 3 years ago • 1 comments

It is found that the attribute @JSX makes the printer function preserve the JSX expression. https://github.com/rescript-lang/syntax/issues/539#issuecomment-1186403650 Changing the JSX PPX to keep the @JSX attribute after transformation, it prints as below. The checking of the call expression should be turned off by the way. It can be used in the compiler emitter to print the JSX in preserve mode.

// expected
let make = ({msg}) => ReactDOMRe.createDOMElementVariadic("div", [{msg->React.string}])

// generated
let make = ({msg}) => <ReactDOMRe.createDOMElementVariadic>  </ReactDOMRe.createDOMElementVariadic>

mununki avatar Jul 17 '22 05:07 mununki

The related functions to print JSX need to be updated as per changes by JSX V4, such as printJsxExpression, printJsxName. They look working with only V3. Plus, those functions can be used to preserve the JSX in the compiler.

mununki avatar Aug 03 '22 16:08 mununki

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

stale[bot] avatar May 28 '23 15:05 stale[bot]