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

423 lines
10 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 170,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 1,
"end": 20,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 10,
"end": 19,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
"start": 10,
"end": 13,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 10,
"end": 13,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "TsLiteralType",
"span": {
"start": 16,
"end": 19,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 16,
"end": 19,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 21,
"end": 38,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 30,
"end": 37,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 30,
"end": 33,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 30,
"end": 31,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 30,
"end": 31,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
{
"type": "TsTypeReference",
"span": {
"start": 36,
"end": 37,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 36,
"end": 37,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 40,
"end": 51,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 44,
"end": 50,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 44,
"end": 47,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 47,
"end": 50,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 49,
"end": 50,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 49,
"end": 50,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "SwitchStatement",
"span": {
"start": 52,
"end": 170,
"ctxt": 0
},
"discriminant": {
"type": "Identifier",
"span": {
"start": 60,
"end": 63,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"cases": [
{
"type": "SwitchCase",
"span": {
"start": 71,
"end": 80,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
"start": 76,
"end": 79,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"consequent": []
},
{
"type": "SwitchCase",
"span": {
"start": 85,
"end": 109,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
"start": 90,
"end": 93,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 103,
"end": 109,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 114,
"end": 168,
"ctxt": 0
},
"test": null,
"consequent": [
{
"type": "ExpressionStatement",
"span": {
"start": 131,
"end": 153,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 131,
"end": 152,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 131,
"end": 134,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 137,
"end": 152,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 137,
"end": 149,
"ctxt": 0
},
"expression": {
"type": "TsAsExpression",
"span": {
"start": 138,
"end": 148,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 138,
"end": 141,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 145,
"end": 148,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 145,
"end": 146,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 145,
"end": 146,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
},
"property": {
"type": "Computed",
"span": {
"start": 149,
"end": 152,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
"start": 150,
"end": 151,
"ctxt": 0
},
"value": 0.0
}
}
}
}
},
{
"type": "BreakStatement",
"span": {
"start": 162,
"end": 168,
"ctxt": 0
},
"label": null
}
]
}
]
}
],
"interpreter": null
}