esprima
esprima copied to clipboard
Support JSX fragments
Steps to reproduce
esprima.parse('<></>', { jsx: true })
Expected output
// excludes location information for brevity
{
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "JSXFragment",
"openingFragment": {
"type": "JSXOpeningFragment"
},
"closingFragment": {
"type": "JSXClosingFragment"
}
}
}
],
"sourceType": "module"
}
Actual output
This exception is thrown: Line 1: Unexpected token >
Relevant references
Looks like jsx-parser.ts
would have to change here, and possibly elsewhere. This syntax works fine in @babel/parser
and acorn
.