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

457 lines
12 KiB
JSON

{
"type": "Script",
"span": {
"start": 28,
"end": 206,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 28,
"end": 69,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 42,
"end": 68,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 42,
"end": 48,
"ctxt": 0
},
"value": "envVar",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 48,
"end": 68,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 50,
"end": 68,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 50,
"end": 56,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 59,
"end": 68,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 70,
"end": 123,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 74,
"end": 100,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 74,
"end": 87,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 81,
"end": 87,
"ctxt": 0
},
"value": "envVar",
"optional": false
}
},
"right": {
"type": "TemplateLiteral",
"span": {
"start": 92,
"end": 100,
"ctxt": 0
},
"expressions": [],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 93,
"end": 99,
"ctxt": 0
},
"tail": true,
"cooked": "string",
"raw": "string"
}
]
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 102,
"end": 123,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 106,
"end": 121,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 106,
"end": 121,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 106,
"end": 118,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 106,
"end": 112,
"ctxt": 0
},
"value": "envVar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 113,
"end": 118,
"ctxt": 0
},
"value": "slice",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 119,
"end": 120,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
],
"typeArguments": null
}
}
]
},
"alternate": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 125,
"end": 163,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 139,
"end": 163,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 139,
"end": 142,
"ctxt": 0
},
"value": "obj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 142,
"end": 163,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 144,
"end": 163,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 144,
"end": 158,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 145,
"end": 157,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 145,
"end": 149,
"ctxt": 0
},
"value": "test",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 149,
"end": 157,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 151,
"end": 157,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
},
{
"type": "TsTypeLiteral",
"span": {
"start": 161,
"end": 163,
"ctxt": 0
},
"members": []
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 164,
"end": 206,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 168,
"end": 181,
"ctxt": 0
},
"operator": "in",
"left": {
"type": "TemplateLiteral",
"span": {
"start": 168,
"end": 174,
"ctxt": 0
},
"expressions": [],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 169,
"end": 173,
"ctxt": 0
},
"tail": true,
"cooked": "test",
"raw": "test"
}
]
},
"right": {
"type": "Identifier",
"span": {
"start": 178,
"end": 181,
"ctxt": 0
},
"value": "obj",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 183,
"end": 206,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 187,
"end": 204,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 187,
"end": 204,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 187,
"end": 201,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 187,
"end": 195,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 187,
"end": 190,
"ctxt": 0
},
"value": "obj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 191,
"end": 195,
"ctxt": 0
},
"value": "test",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 196,
"end": 201,
"ctxt": 0
},
"value": "slice",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 202,
"end": 203,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
],
"typeArguments": null
}
}
]
},
"alternate": null
}
],
"interpreter": null
}