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

624 lines
19 KiB
JSON

{
"type": "Script",
"span": {
"start": 117,
"end": 314,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 117,
"end": 139,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 123,
"end": 139,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 123,
"end": 127,
"ctxt": 0
},
"value": "list",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 127,
"end": 134,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 129,
"end": 134,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 129,
"end": 132,
"ctxt": 0
},
"kind": "any"
}
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 137,
"end": 139,
"ctxt": 0
},
"elements": []
},
"definite": false
}
]
},
{
"type": "ForOfStatement",
"span": {
"start": 140,
"end": 314,
"ctxt": 0
},
"await": null,
"left": {
"type": "VariableDeclaration",
"span": {
"start": 145,
"end": 155,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 151,
"end": 155,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 151,
"end": 155,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
},
"right": {
"type": "Identifier",
"span": {
"start": 159,
"end": 163,
"ctxt": 0
},
"value": "list",
"optional": false
},
"body": {
"type": "BlockStatement",
"span": {
"start": 165,
"end": 314,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 171,
"end": 239,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 171,
"end": 239,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 171,
"end": 180,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 171,
"end": 178,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 171,
"end": 175,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 176,
"end": 178,
"ctxt": 0
},
"value": "sp",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 179,
"end": 180,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 183,
"end": 239,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 183,
"end": 197,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 183,
"end": 192,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 183,
"end": 190,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 183,
"end": 187,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 188,
"end": 190,
"ctxt": 0
},
"value": "sp",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 191,
"end": 192,
"ctxt": 0
},
"value": "r",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 193,
"end": 197,
"ctxt": 0
},
"value": "find",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 198,
"end": 238,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 199,
"end": 205,
"ctxt": 0
},
"value": "k",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 200,
"end": 205,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 202,
"end": 205,
"ctxt": 0
},
"kind": "any"
}
}
}
],
"body": {
"type": "BinaryExpression",
"span": {
"start": 210,
"end": 238,
"ctxt": 0
},
"operator": "==",
"left": {
"type": "MemberExpression",
"span": {
"start": 210,
"end": 213,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 210,
"end": 211,
"ctxt": 0
},
"value": "k",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 212,
"end": 213,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 217,
"end": 238,
"ctxt": 0
},
"expression": {
"type": "ConditionalExpression",
"span": {
"start": 218,
"end": 237,
"ctxt": 0
},
"test": {
"type": "MemberExpression",
"span": {
"start": 218,
"end": 225,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 218,
"end": 222,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 223,
"end": 225,
"ctxt": 0
},
"value": "xp",
"optional": false
}
},
"consequent": {
"type": "StringLiteral",
"span": {
"start": 228,
"end": 231,
"ctxt": 0
},
"value": "1",
"raw": "'1'"
},
"alternate": {
"type": "StringLiteral",
"span": {
"start": 234,
"end": 237,
"ctxt": 0
},
"value": "0",
"raw": "'0'"
}
}
}
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
}
}
},
{
"type": "ForOfStatement",
"span": {
"start": 244,
"end": 312,
"ctxt": 0
},
"await": null,
"left": {
"type": "VariableDeclaration",
"span": {
"start": 249,
"end": 259,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 255,
"end": 259,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 255,
"end": 259,
"ctxt": 0
},
"value": "item",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
},
"right": {
"type": "MemberExpression",
"span": {
"start": 263,
"end": 269,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 263,
"end": 267,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 268,
"end": 269,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"body": {
"type": "BlockStatement",
"span": {
"start": 271,
"end": 312,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 281,
"end": 306,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 281,
"end": 306,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 281,
"end": 287,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 281,
"end": 285,
"ctxt": 0
},
"value": "item",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 286,
"end": 287,
"ctxt": 0
},
"value": "v",
"optional": false
}
},
"right": {
"type": "UnaryExpression",
"span": {
"start": 290,
"end": 306,
"ctxt": 0
},
"operator": "!",
"argument": {
"type": "UnaryExpression",
"span": {
"start": 291,
"end": 306,
"ctxt": 0
},
"operator": "!",
"argument": {
"type": "OptionalChainingExpression",
"span": {
"start": 292,
"end": 306,
"ctxt": 0
},
"questionDotToken": {
"start": 298,
"end": 299,
"ctxt": 0
},
"base": {
"type": "MemberExpression",
"span": {
"start": 292,
"end": 306,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 292,
"end": 298,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 292,
"end": 296,
"ctxt": 0
},
"value": "item",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 297,
"end": 298,
"ctxt": 0
},
"value": "t",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 300,
"end": 306,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
}
}
}
}
]
}
}
]
}
}
],
"interpreter": null
}