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

423 lines
10 KiB
JSON

{
"type": "Script",
"span": {
"start": 2,
"end": 182,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 2,
"end": 21,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 11,
"end": 20,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
"start": 11,
"end": 14,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 11,
"end": 14,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "TsLiteralType",
"span": {
"start": 17,
"end": 20,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 17,
"end": 20,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 23,
"end": 40,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 28,
"end": 29,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 32,
"end": 39,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 32,
"end": 35,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 32,
"end": 33,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 32,
"end": 33,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
{
"type": "TsTypeReference",
"span": {
"start": 38,
"end": 39,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 38,
"end": 39,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 44,
"end": 55,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 48,
"end": 54,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 48,
"end": 51,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 51,
"end": 54,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 53,
"end": 54,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 53,
"end": 54,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "SwitchStatement",
"span": {
"start": 57,
"end": 182,
"ctxt": 0
},
"discriminant": {
"type": "Identifier",
"span": {
"start": 65,
"end": 68,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"cases": [
{
"type": "SwitchCase",
"span": {
"start": 77,
"end": 86,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
"start": 82,
"end": 85,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"consequent": []
},
{
"type": "SwitchCase",
"span": {
"start": 92,
"end": 117,
"ctxt": 0
},
"test": {
"type": "StringLiteral",
"span": {
"start": 97,
"end": 100,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"consequent": [
{
"type": "BreakStatement",
"span": {
"start": 111,
"end": 117,
"ctxt": 0
},
"label": null
}
]
},
{
"type": "SwitchCase",
"span": {
"start": 123,
"end": 179,
"ctxt": 0
},
"test": null,
"consequent": [
{
"type": "ExpressionStatement",
"span": {
"start": 141,
"end": 163,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 141,
"end": 162,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 141,
"end": 144,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "MemberExpression",
"span": {
"start": 147,
"end": 162,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 147,
"end": 159,
"ctxt": 0
},
"expression": {
"type": "TsAsExpression",
"span": {
"start": 148,
"end": 158,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 148,
"end": 151,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 155,
"end": 158,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 155,
"end": 156,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 155,
"end": 156,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
},
"property": {
"type": "Computed",
"span": {
"start": 159,
"end": 162,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
"start": 160,
"end": 161,
"ctxt": 0
},
"value": 0.0
}
}
}
}
},
{
"type": "BreakStatement",
"span": {
"start": 173,
"end": 179,
"ctxt": 0
},
"label": null
}
]
}
]
}
],
"interpreter": null
}