Expression
Expression
- properties
- operator: string
- left: LVal
- right: Expression
t.assignmentExpression('string', t.identifier('lval'), t.identifier('expr'))
{
"type": "AssignmentExpression",
"operator": "string",
"left": {
"type": "Identifier",
"name": "lval"
},
"right": {
"type": "Identifier",
"name": "expr"
}
}
lval string expr
Binary, Expression
- properties
- operator: BINARY_OPERATORS
- left: Expression
- right: Expression
t.binaryExpression('+', t.identifier('expr'), t.identifier('expr'))
{
"type": "BinaryExpression",
"operator": "+",
"left": {
"type": "Identifier",
"name": "expr"
},
"right": {
"type": "Identifier",
"name": "expr"
}
}
expr + expr
- properties
- value: string
t.directiveLiteral('string')
{
"type": "DirectiveLiteral",
"value": "string"
}
"string"
Scopable, BlockParent, Block, Statement
- properties
- body: Statement
- directives: Directive
t.blockStatement([t.returnStatement(t.identifier('statement'))], [])
{
"type": "BlockStatement",
"body": [
{
"type": "ReturnStatement",
"argument": {
"type": "Identifier",
"name": "statement"
}
}
],
"directives": []
}
{
return statement;
}
Statement, Terminatorless, CompletionStatement
Expression
- properties
- callee: Expression
- arguments: Expression,SpreadElement,JSXNamespacedName
t.callExpression(t.identifier('expr'), [t.identifier('expr')])
{
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "expr"
},
"arguments": [
{
"type": "Identifier",
"name": "expr"
}
]
}
expr(expr)
Scopable, BlockParent
Expression, Conditional
Statement, Terminatorless, CompletionStatement
Statement
Statement, BlockParent, Loop, While, Scopable
Statement
Statement, ExpressionWrapper
- properties
- program: Program
t.file(t.program([]))
{
"type": "File",
"program": {
"type": "Program",
"body": [],
"directives": [],
"sourceType": "script"
},
"comments": null,
"tokens": null
}
Scopable, Statement, For, BlockParent, Loop, ForXStatement
Scopable, Statement, For, BlockParent, Loop
Scopable, Function, BlockParent, FunctionParent, Statement, Pureish, Declaration
- properties
- id: Identifier
- params: LVal
- body: BlockStatement
- generator: boolean
- async: boolean
t.functionDeclaration(t.identifier('identifier'), [t.identifier('lval')], t.blockStatement([]), false, false)
{
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "identifier"
},
"params": [
{
"type": "Identifier",
"name": "lval"
}
],
"body": {
"type": "BlockStatement",
"body": [],
"directives": []
},
"generator": false,
"async": false
}
function identifier(lval) {}
Scopable, Function, BlockParent, FunctionParent, Expression, Pureish
Statement, Conditional
Statement
Expression, Pureish, Literal, Immutable
- properties
- value: string
t.stringLiteral('string')
{
"type": "StringLiteral",
"value": "string"
}
"string"
Expression, Pureish, Literal, Immutable
- properties
- value: number
t.numericLiteral(42)
{
"type": "NumericLiteral",
"value": 42
}
42
Expression, Pureish, Literal, Immutable
Expression, Pureish, Literal, Immutable
- properties
- value: boolean
t.booleanLiteral(true)
{
"type": "BooleanLiteral",
"value": true
}
true
Expression, Literal
- properties
- pattern: string
- flags: string
t.regExpLiteral('string', "")
{
"type": "RegExpLiteral",
"pattern": "string",
"flags": ""
}
/string/
Binary, Expression
- properties
- operator: LOGICAL_OPERATORS
- left: Expression
- right: Expression
t.logicalExpression('&&', t.identifier('expr'), t.identifier('expr'))
{
"type": "LogicalExpression",
"operator": "&&",
"left": {
"type": "Identifier",
"name": "expr"
},
"right": {
"type": "Identifier",
"name": "expr"
}
}
expr && expr
Expression, LVal
- properties
- object: Expression
- property:
- computed:
- optional: true,false
t.memberExpression(t.identifier('expr'), t.identifier('identifier'), false, true)
{
"type": "MemberExpression",
"object": {
"type": "Identifier",
"name": "expr"
},
"property": {
"type": "Identifier",
"name": "identifier"
},
"computed": false,
"optional": true
}
expr?.identifier
Scopable, BlockParent, Block
- properties
- body: Statement
- directives: Directive
- sourceType: script,module
t.program([t.returnStatement(t.identifier('statement'))], [], "script")
{
"type": "Program",
"body": [
{
"type": "ReturnStatement",
"argument": {
"type": "Identifier",
"name": "statement"
}
}
],
"directives": [],
"sourceType": "script"
}
return statement;
Expression
UserWhitespacable, Function, Scopable, BlockParent, FunctionParent, Method, ObjectMember
- properties
- kind: method,get,set
- key:
- params: LVal
- body: BlockStatement
- computed: boolean
t.objectMethod("method", t.identifier('identifier'), [t.identifier('lval')], t.blockStatement([]), false)
{
"type": "ObjectMethod",
"kind": "method",
"key": {
"type": "Identifier",
"name": "identifier"
},
"params": [
{
"type": "Identifier",
"name": "lval"
}
],
"body": {
"type": "BlockStatement",
"body": [],
"directives": []
},
"computed": false
}
identifier(lval) {}
UserWhitespacable, Property, ObjectMember
- properties
- key:
- value: Expression,PatternLike
- computed: boolean
- shorthand: boolean
- decorators: Decorator
t.objectProperty(t.identifier('identifier'), t.identifier('expr'), false, false, )
{
"type": "ObjectProperty",
"key": {
"type": "Identifier",
"name": "identifier"
},
"value": {
"type": "Identifier",
"name": "expr"
},
"computed": false,
"shorthand": false,
"decorators": null
}
identifier: expr
LVal, PatternLike
- properties
- argument: LVal
t.restElement(t.identifier('lval'))
{
"type": "RestElement",
"argument": {
"type": "Identifier",
"name": "lval"
}
}
...lval
Statement, Terminatorless, CompletionStatement
Expression
Statement, BlockParent, Scopable
Expression
Statement, Terminatorless, CompletionStatement
Statement
UnaryLike, Expression
- properties
- operator: UNARY_OPERATORS
- argument: Expression
- prefix:
t.unaryExpression('!', t.identifier('expr'), true)
{
"type": "UnaryExpression",
"operator": "!",
"argument": {
"type": "Identifier",
"name": "expr"
},
"prefix": true
}
!expr
Expression
- properties
- operator: UPDATE_OPERATORS
- argument: Expression
- prefix:
t.updateExpression('++', t.identifier('expr'), false)
{
"type": "UpdateExpression",
"operator": "++",
"argument": {
"type": "Identifier",
"name": "expr"
},
"prefix": false
}
expr++
Statement, Declaration
- properties
- kind: var,let,const
- declarations: VariableDeclarator
t.variableDeclaration('var', [t.variableDeclarator(t.identifier('hoge'), t.numericLiteral(1))])
{
"type": "VariableDeclaration",
"kind": "var",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "hoge"
},
"init": {
"type": "NumericLiteral",
"value": 1
}
}
]
}
var hoge = 1;
Statement, BlockParent, Loop, While, Scopable
Statement