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

632 lines
20 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 116,
"end": 313,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 116,
"end": 138,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 122,
"end": 138,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 122,
"end": 126,
"ctxt": 0
},
"value": "list",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 126,
"end": 133,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 128,
"end": 133,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 128,
"end": 131,
"ctxt": 0
},
"kind": "any"
}
}
}
},
"init": {
"type": "ArrayExpression",
"span": {
"start": 136,
"end": 138,
"ctxt": 0
},
"elements": []
},
"definite": false
}
]
},
{
"type": "ForOfStatement",
"span": {
"start": 139,
"end": 313,
"ctxt": 0
},
"await": null,
"left": {
"type": "VariableDeclaration",
"span": {
"start": 144,
"end": 154,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 150,
"end": 154,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 150,
"end": 154,
"ctxt": 0
},
"value": "comp",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
},
"right": {
"type": "Identifier",
"span": {
"start": 158,
"end": 162,
"ctxt": 0
},
"value": "list",
"optional": false
},
"body": {
"type": "BlockStatement",
"span": {
"start": 164,
"end": 313,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 170,
"end": 238,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 170,
"end": 238,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 170,
"end": 179,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 170,
"end": 177,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 170,
"end": 174,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 175,
"end": 177,
"ctxt": 0
},
"value": "sp",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 178,
"end": 179,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
"right": {
"type": "CallExpression",
"span": {
"start": 182,
"end": 238,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 182,
"end": 196,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 182,
"end": 191,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 182,
"end": 189,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 182,
"end": 186,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 187,
"end": 189,
"ctxt": 0
},
"value": "sp",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 190,
"end": 191,
"ctxt": 0
},
"value": "r",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 192,
"end": 196,
"ctxt": 0
},
"value": "find",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "ArrowFunctionExpression",
"span": {
"start": 197,
"end": 237,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 198,
"end": 204,
"ctxt": 0
},
"value": "k",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 199,
"end": 204,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 201,
"end": 204,
"ctxt": 0
},
"kind": "any"
}
}
}
],
"body": {
"type": "BinaryExpression",
"span": {
"start": 209,
"end": 237,
"ctxt": 0
},
"operator": "==",
"left": {
"type": "MemberExpression",
"span": {
"start": 209,
"end": 212,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 209,
"end": 210,
"ctxt": 0
},
"value": "k",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 211,
"end": 212,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 216,
"end": 237,
"ctxt": 0
},
"expression": {
"type": "ConditionalExpression",
"span": {
"start": 217,
"end": 236,
"ctxt": 0
},
"test": {
"type": "MemberExpression",
"span": {
"start": 217,
"end": 224,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 217,
"end": 221,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 222,
"end": 224,
"ctxt": 0
},
"value": "xp",
"optional": false
}
},
"consequent": {
"type": "StringLiteral",
"span": {
"start": 227,
"end": 230,
"ctxt": 0
},
"value": "1",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"alternate": {
"type": "StringLiteral",
"span": {
"start": 233,
"end": 236,
"ctxt": 0
},
"value": "0",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
}
}
],
"typeArguments": null
}
}
},
{
"type": "ForOfStatement",
"span": {
"start": 243,
"end": 311,
"ctxt": 0
},
"await": null,
"left": {
"type": "VariableDeclaration",
"span": {
"start": 248,
"end": 258,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 254,
"end": 258,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 254,
"end": 258,
"ctxt": 0
},
"value": "item",
"optional": false,
"typeAnnotation": null
},
"init": null,
"definite": false
}
]
},
"right": {
"type": "MemberExpression",
"span": {
"start": 262,
"end": 268,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 262,
"end": 266,
"ctxt": 0
},
"value": "comp",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 267,
"end": 268,
"ctxt": 0
},
"value": "c",
"optional": false
}
},
"body": {
"type": "BlockStatement",
"span": {
"start": 270,
"end": 311,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 280,
"end": 305,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 280,
"end": 305,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 280,
"end": 286,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 280,
"end": 284,
"ctxt": 0
},
"value": "item",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 285,
"end": 286,
"ctxt": 0
},
"value": "v",
"optional": false
}
},
"right": {
"type": "UnaryExpression",
"span": {
"start": 289,
"end": 305,
"ctxt": 0
},
"operator": "!",
"argument": {
"type": "UnaryExpression",
"span": {
"start": 290,
"end": 305,
"ctxt": 0
},
"operator": "!",
"argument": {
"type": "OptionalChainingExpression",
"span": {
"start": 291,
"end": 305,
"ctxt": 0
},
"questionDotToken": {
"start": 297,
"end": 298,
"ctxt": 0
},
"base": {
"type": "MemberExpression",
"span": {
"start": 291,
"end": 305,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 291,
"end": 297,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 291,
"end": 295,
"ctxt": 0
},
"value": "item",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 296,
"end": 297,
"ctxt": 0
},
"value": "t",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 299,
"end": 305,
"ctxt": 0
},
"value": "length",
"optional": false
}
}
}
}
}
}
}
]
}
}
]
}
}
],
"interpreter": null
}