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

242 lines
5.4 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 80,
"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": 77,
"ctxt": 0
},
"expression": {
"type": "ConditionalExpression",
"span": {
"start": 55,
"end": 76,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 55,
"end": 59,
"ctxt": 0
},
"value": "cond",
"optional": false
},
"consequent": {
"type": "AssignmentExpression",
"span": {
"start": 62,
"end": 68,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 62,
"end": 63,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 66,
"end": 68,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
},
"alternate": {
"type": "AssignmentExpression",
"span": {
"start": 71,
"end": 76,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 71,
"end": 72,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 75,
"end": 76,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 78,
"end": 80,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 78,
"end": 79,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
],
"interpreter": null
}