benjamn / ast-types

Esprima-compatible implementation of the Mozilla JS Parser API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support `**` (exponentiation) as a BinaryOperator for BinaryExpression's

jrop opened this issue · comments

commented

For instance: the AST for x**y is:

BinaryExpression {
  operator: '**',
  left: Identifier('x'),
  right: Identifier('y'),
}

Currently, when I try to create a ** node:

builders.binaryExpression('**', id('x'), id('y'))

I get the following error

"**" does not match field "operator": == | != | === | !== | < | <= | > | >= | << | >> | >>> | + | - | * | / | % | & | | | ^ | in | instanceof | .. of type BinaryExpression
commented

This is not part of ESTree: /estree/estree/blob/master/es5.md#binaryexpression
ast-types uses esprima, which sticks to those definitions.