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

463 lines
12 KiB
JSON

{
"type": "Script",
"span": {
"start": 2,
"end": 216,
"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",
"raw": "\"a\""
}
},
{
"type": "TsLiteralType",
"span": {
"start": 17,
"end": 20,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
"start": 17,
"end": 20,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
}
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 22,
"end": 39,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 27,
"end": 28,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 31,
"end": 38,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 31,
"end": 34,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 31,
"end": 32,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 31,
"end": 32,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
{
"type": "TsTypeReference",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 50,
"end": 51,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 52,
"end": 58,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 52,
"end": 58,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 55,
"end": 58,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 57,
"end": 58,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 57,
"end": 58,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 41,
"end": 216,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 60,
"end": 216,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 66,
"end": 214,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 70,
"end": 81,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
"start": 70,
"end": 73,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 78,
"end": 81,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 83,
"end": 110,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 93,
"end": 104,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 100,
"end": 103,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
]
},
"alternate": {
"type": "IfStatement",
"span": {
"start": 120,
"end": 214,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 124,
"end": 135,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
"start": 124,
"end": 127,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 132,
"end": 135,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 137,
"end": 164,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 147,
"end": 158,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 154,
"end": 157,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
"start": 174,
"end": 214,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 185,
"end": 208,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 192,
"end": 207,
"ctxt": 0
},
"object": {
"type": "ParenthesisExpression",
"span": {
"start": 192,
"end": 204,
"ctxt": 0
},
"expression": {
"type": "TsAsExpression",
"span": {
"start": 193,
"end": 203,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 193,
"end": 196,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"typeAnnotation": {
"type": "TsArrayType",
"span": {
"start": 200,
"end": 203,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 200,
"end": 201,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
},
"property": {
"type": "Computed",
"span": {
"start": 204,
"end": 207,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
"start": 205,
"end": 206,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
]
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}