swc/crates/swc_ecma_parser/tests/tsc/controlFlowWithTemplateLiterals.json
2022-02-04 17:08:38 +09:00

507 lines
13 KiB
JSON

{
"type": "Script",
"span": {
"start": 27,
"end": 205,
"ctxt": 0
},
"body": [
{
"type": "VariableDeclaration",
"span": {
"start": 27,
"end": 68,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 41,
"end": 67,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 41,
"end": 47,
"ctxt": 0
},
"value": "envVar",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 47,
"end": 67,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 49,
"end": 67,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 49,
"end": 55,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 58,
"end": 67,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 69,
"end": 122,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 73,
"end": 99,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "UnaryExpression",
"span": {
"start": 73,
"end": 86,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 80,
"end": 86,
"ctxt": 0
},
"value": "envVar",
"optional": false
}
},
"right": {
"type": "TemplateLiteral",
"span": {
"start": 91,
"end": 99,
"ctxt": 0
},
"expressions": [],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 92,
"end": 98,
"ctxt": 0
},
"tail": true,
"cooked": {
"type": "StringLiteral",
"span": {
"start": 92,
"end": 98,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": false
}
},
"raw": {
"type": "StringLiteral",
"span": {
"start": 92,
"end": 98,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": false
}
}
}
]
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 101,
"end": 122,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 105,
"end": 120,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 105,
"end": 120,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 105,
"end": 117,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 105,
"end": 111,
"ctxt": 0
},
"value": "envVar",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 112,
"end": 117,
"ctxt": 0
},
"value": "slice",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 118,
"end": 119,
"ctxt": 0
},
"value": 0.0
}
}
],
"typeArguments": null
}
}
]
},
"alternate": null
},
{
"type": "VariableDeclaration",
"span": {
"start": 124,
"end": 162,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 138,
"end": 162,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 138,
"end": 141,
"ctxt": 0
},
"value": "obj",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 141,
"end": 162,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 143,
"end": 162,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 143,
"end": 157,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 144,
"end": 156,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 144,
"end": 148,
"ctxt": 0
},
"value": "test",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 148,
"end": 156,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 150,
"end": 156,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
},
{
"type": "TsTypeLiteral",
"span": {
"start": 160,
"end": 162,
"ctxt": 0
},
"members": []
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 163,
"end": 205,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 167,
"end": 180,
"ctxt": 0
},
"operator": "in",
"left": {
"type": "TemplateLiteral",
"span": {
"start": 167,
"end": 173,
"ctxt": 0
},
"expressions": [],
"quasis": [
{
"type": "TemplateElement",
"span": {
"start": 168,
"end": 172,
"ctxt": 0
},
"tail": true,
"cooked": {
"type": "StringLiteral",
"span": {
"start": 168,
"end": 172,
"ctxt": 0
},
"value": "test",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": false
}
},
"raw": {
"type": "StringLiteral",
"span": {
"start": 168,
"end": 172,
"ctxt": 0
},
"value": "test",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": false
}
}
}
]
},
"right": {
"type": "Identifier",
"span": {
"start": 177,
"end": 180,
"ctxt": 0
},
"value": "obj",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 182,
"end": 205,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 186,
"end": 203,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 186,
"end": 203,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 186,
"end": 200,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 186,
"end": 194,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 186,
"end": 189,
"ctxt": 0
},
"value": "obj",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 190,
"end": 194,
"ctxt": 0
},
"value": "test",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 195,
"end": 200,
"ctxt": 0
},
"value": "slice",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 201,
"end": 202,
"ctxt": 0
},
"value": 0.0
}
}
],
"typeArguments": null
}
}
]
},
"alternate": null
}
],
"interpreter": null
}