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

Support for new babel types #132

Closed
tmcw opened this issue Nov 3, 2015 · 8 comments · Fixed by #162
Closed

Support for new babel types #132

tmcw opened this issue Nov 3, 2015 · 8 comments · Fixed by #162
Assignees

Comments

@tmcw
Copy link

tmcw commented Nov 3, 2015

Re: babel/babel#2769

Babel 6.0.0 introduces a new NumericLiteral type that currently is not present in ast-types and breaks the tree traversal.

@benjamn
Copy link
Owner

benjamn commented Nov 3, 2015

Have time to submit a pull request?

@benjamn
Copy link
Owner

benjamn commented Dec 2, 2015

I'm guessing @tmcw doesn't have time for a pull request, which is totally fine. I'll do this as soon as I can.

@hzoo
Copy link
Contributor

hzoo commented Dec 2, 2015

Shouldn't be too bad. I can do it later if you don't - From the changelog

Rename RegexLiteral node to RegExpLiteral.
Rename NumberLiteral node to NumericLiteral.

The MethodDefinition node type has been renamed to ClassMethod and it's FunctionExpression value property has been coerced into the main method node.
The Property node type has been renamed to ObjectProperty.
The Property node type with the boolean flag method has been renamed to ObjectMethod and it's FunctionExpression value property has been coerced into the main method node.
The Literal node type has been unoverloaded and split into BooleanLiteral, RegExpLiteral, NumericLiteral, StringLiteral and NullLiteral.
The SpreadProperty (from object-rest-spread) node type has been split into RestProperty (for ObjectPattern) and SpreadProperty (for ObjectExpression)

@benjamn
Copy link
Owner

benjamn commented Dec 2, 2015

Those are all really worthwhile changes, by the way.

@hzoo
Copy link
Contributor

hzoo commented Dec 2, 2015

Should probably propose them to ESTree anyway (lgtm)

@jamestalmage
Copy link
Contributor

I think this is going to be difficult w/o #57.

For example: attempting to add RegExpLiteral per the spec, I added the following definition:

def("RegExpLiteral")
    .bases("Literal")
    .build("pattern", "flags")
    .field("pattern", String)
    .field("flags", String);

Trying to build a RegExpLiteral Node, you get the following error:

b.regExpLiteral("my-pattern", "ig");
 Error: no value or default function given for field "value" of RegExpLiteral("pattern": string, "flags": string)

This is because core.js defines a required value field for Literal, where the Babel spec uses Literal strictly as a super-type for the more specific nodes (StringLiteral, NullLiteral, etc).

Until ast-types is refactored to allow custom Node definitions, these increasingly divergent AST specs are going to represent a problem.

@hzoo
Copy link
Contributor

hzoo commented Aug 31, 2016

Update: I made #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants