esprima icon indicating copy to clipboard operation
esprima copied to clipboard

Support JSX fragments

Open eventualbuddha opened this issue 4 years ago • 0 comments

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.

eventualbuddha avatar Apr 05 '20 17:04 eventualbuddha