swc/crates/swc_ecma_parser/tests/tsc/controlFlowBinaryAndExpression.json

370 lines
8.2 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 126,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 1,
"end": 34,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 5,
"end": 33,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 5,
"end": 6,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 6,
"end": 33,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 8,
"end": 33,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 8,
"end": 14,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 17,
"end": 23,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 26,
"end": 33,
"ctxt": 0
},
"kind": "boolean"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 35,
"end": 53,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 39,
"end": 52,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 39,
"end": 43,
"ctxt": 0
},
"value": "cond",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 43,
"end": 52,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 45,
"end": 52,
"ctxt": 0
},
"kind": "boolean"
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 55,
"end": 75,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 55,
"end": 74,
"ctxt": 0
},
"operator": "&&",
"left": {
"type": "ParenthesisExpression",
"span": {
"start": 55,
"end": 63,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 56,
"end": 62,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 56,
"end": 57,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 60,
"end": 62,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 67,
"end": 74,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 68,
"end": 73,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 68,
"end": 69,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 72,
"end": 73,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 76,
"end": 78,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 76,
"end": 77,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 99,
"end": 106,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 99,
"end": 105,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 99,
"end": 100,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 103,
"end": 105,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 107,
"end": 123,
"ctxt": 0
},
"expression": {
"type": "BinaryExpression",
"span": {
"start": 107,
"end": 122,
"ctxt": 0
},
"operator": "&&",
"left": {
"type": "Identifier",
"span": {
"start": 107,
"end": 111,
"ctxt": 0
},
"value": "cond",
"optional": false
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 115,
"end": 122,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 116,
"end": 121,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 124,
"end": 126,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
],
"interpreter": null
}