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

585 lines
14 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
2022-02-04 14:17:42 +03:00
"start": 1,
"end": 216,
"ctxt": 0
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 1,
"end": 20,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 10,
"end": 19,
"ctxt": 0
},
"types": [
{
"type": "TsLiteralType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 10,
"end": 13,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 10,
"end": 13,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
{
"type": "TsLiteralType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 16,
"end": 19,
"ctxt": 0
},
"literal": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 16,
"end": 19,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
2022-02-04 14:17:42 +03:00
"start": 21,
"end": 38,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 26,
"end": 27,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 37,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 33,
"ctxt": 0
},
"elemType": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 31,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 30,
"end": 31,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
},
{
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 36,
"end": 37,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 36,
"end": 37,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
]
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 49,
"end": 52,
"ctxt": 0
},
"value": "isS",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
2022-02-04 14:17:42 +03:00
"start": 53,
"end": 57,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 53,
"end": 57,
"ctxt": 0
},
"value": "t",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 54,
"end": 57,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 56,
"end": 57,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 56,
"end": 57,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
2022-02-04 14:17:42 +03:00
"start": 40,
"end": 105,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 67,
"end": 105,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 73,
"end": 103,
"ctxt": 0
},
"argument": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 80,
"end": 102,
"ctxt": 0
},
"operator": "||",
"left": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 80,
"end": 89,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 80,
"end": 81,
"ctxt": 0
},
"value": "t",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 86,
"end": 89,
"ctxt": 0
},
"value": "a",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"right": {
"type": "BinaryExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 93,
"end": 102,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 93,
"end": 94,
"ctxt": 0
},
"value": "t",
"optional": false
},
"right": {
"type": "StringLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 99,
"end": 102,
"ctxt": 0
},
"value": "b",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 58,
"end": 66,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
2022-02-04 14:17:42 +03:00
"start": 60,
"end": 66,
"ctxt": 0
},
"asserts": false,
"paramName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 60,
"end": 61,
"ctxt": 0
},
"value": "t",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 65,
"end": 66,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 65,
"end": 66,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 65,
"end": 66,
"ctxt": 0
},
"value": "S",
"optional": false
},
"typeParams": null
}
}
}
}
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 116,
"end": 117,
"ctxt": 0
},
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
2022-02-04 14:17:42 +03:00
"start": 118,
"end": 124,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 118,
"end": 124,
"ctxt": 0
},
"value": "foo",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
2022-02-04 14:17:42 +03:00
"start": 121,
"end": 124,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
2022-02-04 14:17:42 +03:00
"start": 123,
"end": 124,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 123,
"end": 124,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
2022-02-04 14:17:42 +03:00
"start": 107,
"end": 216,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 126,
"end": 216,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 132,
"end": 214,
"ctxt": 0
},
"test": {
"type": "CallExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 136,
"end": 144,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 136,
"end": 139,
"ctxt": 0
},
"value": "isS",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 140,
"end": 143,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
],
"typeArguments": null
},
"consequent": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 146,
"end": 173,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 156,
"end": 167,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 163,
"end": 166,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 183,
"end": 214,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
2022-02-04 14:17:42 +03:00
"start": 194,
"end": 208,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
2022-02-04 14:17:42 +03:00
"start": 201,
"end": 207,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
2022-02-04 14:17:42 +03:00
"start": 201,
"end": 204,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"property": {
"type": "Computed",
"span": {
2022-02-04 14:17:42 +03:00
"start": 204,
"end": 207,
"ctxt": 0
},
"expression": {
"type": "NumericLiteral",
"span": {
2022-02-04 14:17:42 +03:00
"start": 205,
"end": 206,
"ctxt": 0
},
"value": 0.0
}
}
}
}
]
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}