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

720 lines
16 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 305,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 1,
"end": 15,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 7,
"end": 14,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "StringLiteral",
"span": {
"start": 11,
"end": 14,
"ctxt": 0
},
"value": "a",
"raw": "'a'"
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 16,
"end": 30,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 22,
"end": 29,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 22,
"end": 23,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "StringLiteral",
"span": {
"start": 26,
"end": 29,
"ctxt": 0
},
"value": "b",
"raw": "'b'"
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 31,
"end": 45,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 37,
"end": 44,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"value": "d",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "StringLiteral",
"span": {
"start": 41,
"end": 44,
"ctxt": 0
},
"value": "d",
"raw": "'d'"
},
"definite": false
}
]
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 47,
"end": 73,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 52,
"end": 53,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 56,
"end": 72,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 58,
"end": 70,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 59,
"end": 60,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": true,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 61,
"end": 69,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 63,
"end": 69,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 74,
"end": 100,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 79,
"end": 80,
"ctxt": 0
},
"value": "B",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 83,
"end": 99,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 85,
"end": 97,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": true,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 88,
"end": 96,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 90,
"end": 96,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 102,
"end": 125,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 116,
"end": 124,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 117,
"end": 124,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 119,
"end": 124,
"ctxt": 0
},
"types": [
{
"type": "TsTypeReference",
"span": {
"start": 119,
"end": 120,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 119,
"end": 120,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": null
},
{
"type": "TsTypeReference",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 123,
"end": 124,
"ctxt": 0
},
"value": "B",
"optional": false
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 127,
"end": 184,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 131,
"end": 139,
"ctxt": 0
},
"operator": "in",
"left": {
"type": "StringLiteral",
"span": {
"start": 131,
"end": 134,
"ctxt": 0
},
"value": "a",
"raw": "'a'"
},
"right": {
"type": "Identifier",
"span": {
"start": 138,
"end": 139,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 141,
"end": 184,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 147,
"end": 149,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 147,
"end": 148,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 164,
"end": 171,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 164,
"end": 170,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 164,
"end": 165,
"ctxt": 0
},
"value": "c",
"optional": false
},
"property": {
"type": "Computed",
"span": {
"start": 165,
"end": 170,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 166,
"end": 169,
"ctxt": 0
},
"value": "a",
"raw": "'a'"
}
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 186,
"end": 219,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 190,
"end": 198,
"ctxt": 0
},
"operator": "in",
"left": {
"type": "StringLiteral",
"span": {
"start": 190,
"end": 193,
"ctxt": 0
},
"value": "d",
"raw": "'d'"
},
"right": {
"type": "Identifier",
"span": {
"start": 197,
"end": 198,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 200,
"end": 219,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 206,
"end": 208,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": "c",
"optional": false
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 221,
"end": 272,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 225,
"end": 231,
"ctxt": 0
},
"operator": "in",
"left": {
"type": "Identifier",
"span": {
"start": 225,
"end": 226,
"ctxt": 0
},
"value": "a",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 230,
"end": 231,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 233,
"end": 272,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 239,
"end": 241,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 239,
"end": 240,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 254,
"end": 259,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 254,
"end": 258,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 254,
"end": 255,
"ctxt": 0
},
"value": "c",
"optional": false
},
"property": {
"type": "Computed",
"span": {
"start": 255,
"end": 258,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 256,
"end": 257,
"ctxt": 0
},
"value": "a",
"optional": false
}
}
}
}
]
},
"alternate": null
},
{
"type": "IfStatement",
"span": {
"start": 274,
"end": 305,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 278,
"end": 284,
"ctxt": 0
},
"operator": "in",
"left": {
"type": "Identifier",
"span": {
"start": 278,
"end": 279,
"ctxt": 0
},
"value": "d",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 283,
"end": 284,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 286,
"end": 305,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 292,
"end": 294,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 292,
"end": 293,
"ctxt": 0
},
"value": "c",
"optional": false
}
}
]
},
"alternate": null
}
],
"interpreter": null
}