Closed duaraghav8 closed 8 years ago
take below code:
sendObject ({ name: "foo bar", age: 20 });
The AST for this is (you don't need to see the JSON, its just for reference):
{ "type": "Program", "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "sendObject", "start": 0, "end": 10 }, "arguments": [ { "type": "ObjectExpression", "properties": [ { "key": { "type": "Identifier", "name": "name", "start": 13, "end": 17 }, "value": { "type": "Literal", "value": "foo bar", "start": 19, "end": 28 }, "kind": "init", "start": 13, "end": 28 }, { "key": { "type": "Identifier", "name": "age", "start": 29, "end": 32 }, "value": { "type": "Literal", "value": 20, "start": 34, "end": 36 }, "kind": "init", "start": 29, "end": 36 } ], "start": 12, "end": 37 } ], "start": 0, "end": 38 }, "start": 0, "end": 38 } ], "start": 0, "end": 38 }
Specifically, I'd like to point out the elements of properties array of ObjectExpression node. The node corresponding to name: "foo bar" is:
properties
ObjectExpression
name: "foo bar"
{ "key": { "type": "Identifier", "name": "name", "start": 13, "end": 17 }, "value": { "type": "Literal", "value": "foo bar", "start": 19, "end": 28 }, "kind": "init", "start": 13, "end": 28 }
This node has fields key, value, kind, start, end, but doesn't have any type field (which is necessary for Spider Monkey complaint AST Nodes.
key, value, kind, start, end
type
I've already fixed this on my local module with type: "Property".
type: "Property"
When its decided what type's value to give to PropertyAssignment nodes, let me know and I'll make a PR.
PropertyAssignment
I will second the use of type: "Property" since that is what is used in esprima.
Looks good to me. I defer to you guys on what the best value for type is here. :+1: Thanks @duaraghav8
take below code:
The AST for this is (you don't need to see the JSON, its just for reference):
Specifically, I'd like to point out the elements of
properties
array ofObjectExpression
node. The node corresponding toname: "foo bar"
is:This node has fields
key, value, kind, start, end
, but doesn't have anytype
field (which is necessary for Spider Monkey complaint AST Nodes.I've already fixed this on my local module with
type: "Property"
.When its decided what
type
's value to give toPropertyAssignment
nodes, let me know and I'll make a PR.