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

700 lines
20 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 523,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 10,
"end": 11,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 12,
"end": 40,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 12,
"end": 40,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 13,
"end": 40,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 15,
"end": 40,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 15,
"end": 21,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 24,
"end": 30,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 33,
"end": 40,
"ctxt": 0
},
"kind": "boolean"
}
]
}
}
}
}
],
"decorators": [],
"span": {
"start": 1,
"end": 523,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 42,
"end": 523,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 48,
"end": 89,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 52,
"end": 88,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 52,
"end": 53,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 53,
"end": 80,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 55,
"end": 80,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 55,
"end": 61,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 64,
"end": 70,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 73,
"end": 80,
"ctxt": 0
},
"kind": "boolean"
}
]
}
}
},
"init": {
"type": "BooleanLiteral",
"span": {
"start": 83,
"end": 88,
"ctxt": 0
},
"value": false
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 94,
"end": 135,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 98,
"end": 134,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 98,
"end": 99,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 99,
"end": 126,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 101,
"end": 126,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 101,
"end": 107,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 110,
"end": 116,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 119,
"end": 126,
"ctxt": 0
},
"kind": "boolean"
}
]
}
}
},
"init": {
"type": "BooleanLiteral",
"span": {
"start": 129,
"end": 134,
"ctxt": 0
},
"value": false
},
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 140,
"end": 441,
"ctxt": 0
},
"test": {
"type": "SequenceExpression",
"span": {
"start": 144,
"end": 173,
"ctxt": 0
},
"expressions": [
{
"type": "AssignmentExpression",
"span": {
"start": 144,
"end": 150,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 144,
"end": 145,
"ctxt": 0
},
"value": "y",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 148,
"end": 150,
"ctxt": 0
},
"value": "",
"raw": "\"\""
}
},
{
"type": "BinaryExpression",
"span": {
"start": 152,
"end": 173,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 152,
"end": 160,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 159,
"end": 160,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 165,
"end": 173,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
}
]
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 175,
"end": 246,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 185,
"end": 187,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 185,
"end": 186,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 206,
"end": 208,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 227,
"end": 229,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 227,
"end": 228,
"ctxt": 0
},
"value": "z",
"optional": false
}
}
]
},
"alternate": {
"type": "IfStatement",
"span": {
"start": 256,
"end": 441,
"ctxt": 0
},
"test": {
"type": "SequenceExpression",
"span": {
"start": 260,
"end": 288,
"ctxt": 0
},
"expressions": [
{
"type": "AssignmentExpression",
"span": {
"start": 260,
"end": 265,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 260,
"end": 261,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 264,
"end": 265,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
},
{
"type": "BinaryExpression",
"span": {
"start": 267,
"end": 288,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 267,
"end": 275,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 274,
"end": 275,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 280,
"end": 288,
"ctxt": 0
},
"value": "number",
"raw": "\"number\""
}
}
]
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 290,
"end": 360,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 300,
"end": 302,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 300,
"end": 301,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 321,
"end": 323,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 321,
"end": 322,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 342,
"end": 344,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 342,
"end": 343,
"ctxt": 0
},
"value": "z",
"optional": false
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
"start": 370,
"end": 441,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 380,
"end": 382,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 380,
"end": 381,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 402,
"end": 404,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 402,
"end": 403,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 423,
"end": 425,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 423,
"end": 424,
"ctxt": 0
},
"value": "z",
"optional": false
}
}
]
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 446,
"end": 448,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 446,
"end": 447,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 482,
"end": 484,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 482,
"end": 483,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 499,
"end": 501,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 499,
"end": 500,
"ctxt": 0
},
"value": "z",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}