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

570 lines
14 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 2,
"end": 217,
"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": 53,
"ctxt": 0
},
"value": "isS",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 54,
"end": 58,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 54,
"end": 58,
"ctxt": 0
},
"value": "t",
"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": 106,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 68,
"end": 106,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 74,
"end": 104,
"ctxt": 0
},
"argument": {
"type": "BinaryExpression",
"span": {
"start": 81,
"end": 103,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "BinaryExpression",
"span": {
"start": 81,
"end": 90,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
"start": 81,
"end": 82,
"ctxt": 0
},
"value": "t",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 87,
"end": 90,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 94,
"end": 103,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
"start": 94,
"end": 95,
"ctxt": 0
},
"value": "t",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
"start": 100,
"end": 103,
"ctxt": 0
},
"value": "b",
"raw": "\"b\""
}
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 59,
"end": 67,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 61,
"end": 67,
"ctxt": 0
},
"asserts": false,
"paramName": {
"type": "Identifier",
"span": {
"start": 61,
"end": 62,
"ctxt": 0
},
"value": "t",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 66,
"end": 67,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 66,
"end": 67,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 66,
"end": 67,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 117,
"end": 118,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 119,
"end": 125,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 119,
"end": 125,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 122,
"end": 125,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 108,
"end": 217,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 127,
"end": 217,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 133,
"end": 215,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
"start": 137,
"end": 145,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 137,
"end": 140,
"ctxt": 0
},
"value": "isS",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 141,
"end": 144,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
],
"typeArguments": null
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 147,
"end": 174,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 157,
"end": 168,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 164,
"end": 167,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
"start": 184,
"end": 215,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 195,
"end": 209,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 202,
"end": 208,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 202,
"end": 205,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"property": {
"type": "Computed",
"span": {
"start": 205,
"end": 208,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": 0.0,
"raw": "0"
}
}
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}