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

436 lines
11 KiB
JSON

{
"type": "Script",
"span": {
"start": 18,
"end": 270,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 18,
"end": 92,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 23,
"end": 24,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 27,
"end": 91,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 33,
"end": 54,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 33,
"end": 38,
"ctxt": 0
},
"value": "other",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 38,
"end": 53,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 40,
"end": 53,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 40,
"end": 46,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 49,
"end": 53,
"ctxt": 0
},
"kind": "null"
}
]
}
},
"typeParams": null
},
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 60,
"end": 73,
"ctxt": 0
},
"value": "index",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 65,
"end": 73,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 67,
"end": 73,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 74,
"end": 89,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 76,
"end": 89,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 76,
"end": 82,
"ctxt": 0
},
"kind": "number"
},
{
"type": "TsKeywordType",
"span": {
"start": 85,
"end": 89,
"ctxt": 0
},
"kind": "null"
}
]
}
},
"readonly": false,
"static": false,
"span": {
"start": 59,
"end": 89,
"ctxt": 0
}
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 93,
"end": 116,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 107,
"end": 115,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 107,
"end": 112,
"ctxt": 0
},
"value": "value",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 112,
"end": 115,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 114,
"end": 115,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 114,
"end": 115,
"ctxt": 0
},
"value": "A",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 117,
"end": 270,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 121,
"end": 139,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "MemberExpression",
"span": {
"start": 121,
"end": 130,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 121,
"end": 126,
"ctxt": 0
},
"value": "value",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 127,
"end": 130,
"ctxt": 0
},
"value": "foo",
"optional": false
}
},
"right": {
"type": "NullLiteral",
"span": {
"start": 135,
"end": 139,
"ctxt": 0
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 141,
"end": 270,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 147,
"end": 172,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 147,
"end": 172,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 147,
"end": 170,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 147,
"end": 156,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 147,
"end": 152,
"ctxt": 0
},
"value": "value",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 153,
"end": 156,
"ctxt": 0
},
"value": "foo",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 157,
"end": 170,
"ctxt": 0
},
"value": "toExponential",
"optional": false
}
},
"arguments": [],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 177,
"end": 188,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 177,
"end": 188,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 177,
"end": 182,
"ctxt": 0
},
"value": "value",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 183,
"end": 188,
"ctxt": 0
},
"value": "other",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 226,
"end": 235,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 226,
"end": 235,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 226,
"end": 231,
"ctxt": 0
},
"value": "value",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 232,
"end": 235,
"ctxt": 0
},
"value": "bar",
"optional": false
}
}
}
]
},
"alternate": null
}
],
"interpreter": null
}