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

694 lines
18 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 18,
"end": 314,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 18,
"end": 83,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 28,
"end": 29,
"ctxt": 0
},
"value": "X",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 30,
"end": 83,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 34,
"end": 56,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 34,
"end": 35,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 36,
"end": 55,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 38,
"end": 55,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 40,
"end": 53,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 40,
"end": 45,
"ctxt": 0
},
"value": "aProp",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 45,
"end": 53,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 47,
"end": 53,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 59,
"end": 81,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 59,
"end": 60,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 61,
"end": 80,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 63,
"end": 80,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 65,
"end": 78,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 65,
"end": 70,
"ctxt": 0
},
"value": "bProp",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 70,
"end": 78,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 72,
"end": 78,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
"typeParams": null
}
]
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 84,
"end": 154,
"ctxt": 0
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 89,
"end": 93,
"ctxt": 0
},
"value": "AorB",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 96,
"end": 153,
"ctxt": 0
},
"types": [
{
"type": "TsTypeLiteral",
"span": {
"start": 96,
"end": 123,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 98,
"end": 108,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 98,
"end": 99,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 99,
"end": 107,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 101,
"end": 107,
"ctxt": 0
},
"kind": "object"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 109,
"end": 121,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 109,
"end": 110,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 110,
"end": 121,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 112,
"end": 121,
"ctxt": 0
},
"kind": "undefined"
}
},
"typeParams": null
}
]
},
{
"type": "TsTypeLiteral",
"span": {
"start": 126,
"end": 153,
"ctxt": 0
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 128,
"end": 141,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 128,
"end": 129,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 129,
"end": 140,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 131,
"end": 140,
"ctxt": 0
},
"kind": "undefined"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 142,
"end": 151,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 142,
"end": 143,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 143,
"end": 151,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 145,
"end": 151,
"ctxt": 0
},
"kind": "object"
}
},
"typeParams": null
}
]
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 156,
"end": 182,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 170,
"end": 181,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 170,
"end": 171,
"ctxt": 0
},
"value": "q",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 171,
"end": 181,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsIntersectionType",
"span": {
"start": 173,
"end": 181,
"ctxt": 0
},
"types": [
{
"type": "TsTypeReference",
"span": {
"start": 173,
"end": 174,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 173,
"end": 174,
"ctxt": 0
},
"value": "X",
"optional": false
},
"typeParams": null
},
{
"type": "TsTypeReference",
"span": {
"start": 177,
"end": 181,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 177,
"end": 181,
"ctxt": 0
},
"value": "AorB",
"optional": false
},
"typeParams": null
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 184,
"end": 314,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 188,
"end": 205,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "MemberExpression",
"span": {
"start": 188,
"end": 191,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 188,
"end": 189,
"ctxt": 0
},
"value": "q",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 190,
"end": 191,
"ctxt": 0
},
"value": "a",
"optional": false
}
},
"right": {
"type": "Identifier",
"span": {
"start": 196,
"end": 205,
"ctxt": 0
},
"value": "undefined",
"optional": false
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 207,
"end": 223,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 211,
"end": 221,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 211,
"end": 220,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 211,
"end": 214,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 211,
"end": 212,
"ctxt": 0
},
"value": "q",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 213,
"end": 214,
"ctxt": 0
},
"value": "a",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 215,
"end": 220,
"ctxt": 0
},
"value": "aProp",
"optional": false
}
}
}
]
},
"alternate": {
"type": "BlockStatement",
"span": {
"start": 229,
"end": 314,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 302,
"end": 312,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 302,
"end": 311,
"ctxt": 0
},
"object": {
"type": "MemberExpression",
"span": {
"start": 302,
"end": 305,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 302,
"end": 303,
"ctxt": 0
},
"value": "q",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 304,
"end": 305,
"ctxt": 0
},
"value": "b",
"optional": false
}
},
"property": {
"type": "Identifier",
"span": {
"start": 306,
"end": 311,
"ctxt": 0
},
"value": "bProp",
"optional": false
}
}
}
]
}
}
],
"interpreter": null
}