Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data structure for export default AN_EXPRESSION #1088

Closed
mikesherov opened this issue Mar 3, 2015 · 1 comment
Closed

data structure for export default AN_EXPRESSION #1088

mikesherov opened this issue Mar 3, 2015 · 1 comment

Comments

@mikesherov
Copy link
Member

Right now, e.g. export default 42; produces a literal as the value of the declaration field. Should it produce an expressionStatement node instead, which has a literal inside it?

If no, then it seems we're unwrapping arbitrary expressions inside the export default syntax, and something like export default (1 + 42); should be similarly unwrapped to have a binaryExpression be the value of the declaration field>

@ariya
Copy link
Contributor

ariya commented Jul 2, 2015

Harmony branch is deprecated. Here is the situation on the master branch.

> require('esprima').parse('export default 42;', { sourceType: 'module'}).body[0]
{ type: 'ExportDefaultDeclaration',
  declaration: { type: 'Literal', value: 42, raw: '42' } }

and for binary expression:

> require('esprima').parse('export default (1+2);', { sourceType: 'module'}).body[0]
{ type: 'ExportDefaultDeclaration',
  declaration: 
   { type: 'BinaryExpression',
     operator: '+',
     left: { type: 'Literal', value: 1, raw: '1' },
     right: { type: 'Literal', value: 2, raw: '2' } } }

According to ESTree:

interface ExportDefaultDeclaration <: Node {
    type: "ExportDefaultDeclaration";
    declaration: Declaration | Expression;
}

Thus, it seems that we are already doing the right thing and there is no issue anymore.

@ariya ariya closed this as completed Jul 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants