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

533 lines
14 KiB
JSON

{
"type": "Script",
"span": {
"start": 41,
"end": 219,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 41,
"end": 127,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 51,
"end": 52,
"ctxt": 0
},
"value": "Y",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 53,
"end": 127,
"ctxt": 0
},
"body": [
{
"type": "TsMethodSignature",
"span": {
"start": 59,
"end": 95,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 59,
"end": 62,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"params": [
{
"type": "Identifier",
"span": {
"start": 66,
"end": 73,
"ctxt": 0
},
"value": "this",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 70,
"end": 73,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 72,
"end": 73,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 72,
"end": 73,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
{
"type": "Identifier",
"span": {
"start": 75,
"end": 87,
"ctxt": 0
},
"value": "arg",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 78,
"end": 87,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeOperator",
"span": {
"start": 80,
"end": 87,
"ctxt": 0
},
"op": "keyof",
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 86,
"end": 87,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 88,
"end": 94,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 90,
"end": 94,
"ctxt": 0
},
"kind": "void"
}
},
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 62,
"end": 65,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 63,
"end": 64,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 63,
"end": 64,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
}
},
{
"type": "TsPropertySignature",
"span": {
"start": 100,
"end": 110,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 100,
"end": 101,
"ctxt": 0
},
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 101,
"end": 109,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 103,
"end": 109,
"ctxt": 0
},
"kind": "number"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 115,
"end": 125,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 115,
"end": 116,
"ctxt": 0
},
"value": "b",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 116,
"end": 124,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 118,
"end": 124,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 129,
"end": 164,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 143,
"end": 163,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 143,
"end": 148,
"ctxt": 0
},
"value": "value",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 148,
"end": 163,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 150,
"end": 163,
"ctxt": 0
},
"types": [
{
"type": "TsTypeReference",
"span": {
"start": 150,
"end": 151,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 150,
"end": 151,
"ctxt": 0
},
"value": "Y",
"optional": false
},
"typeParams": null
},
{
"type": "TsKeywordType",
"span": {
"start": 154,
"end": 163,
"ctxt": 0
},
"kind": "undefined"
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "IfStatement",
"span": {
"start": 166,
"end": 201,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 170,
"end": 175,
"ctxt": 0
},
"value": "value",
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 177,
"end": 201,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 183,
"end": 199,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 183,
"end": 198,
"ctxt": 0
},
"callee": {
"type": "OptionalChainingExpression",
"span": {
"start": 183,
"end": 193,
"ctxt": 0
},
"questionDotToken": {
"start": 188,
"end": 189,
"ctxt": 0
},
"base": {
"type": "MemberExpression",
"span": {
"start": 183,
"end": 193,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 183,
"end": 188,
"ctxt": 0
},
"value": "value",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 190,
"end": 193,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 194,
"end": 197,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
}
],
"typeArguments": null
}
}
]
},
"alternate": null
},
{
"type": "ExpressionStatement",
"span": {
"start": 203,
"end": 219,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 203,
"end": 218,
"ctxt": 0
},
"callee": {
"type": "OptionalChainingExpression",
"span": {
"start": 203,
"end": 213,
"ctxt": 0
},
"questionDotToken": {
"start": 208,
"end": 209,
"ctxt": 0
},
"base": {
"type": "MemberExpression",
"span": {
"start": 203,
"end": 213,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 203,
"end": 208,
"ctxt": 0
},
"value": "value",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 210,
"end": 213,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 214,
"end": 217,
"ctxt": 0
},
"value": "a",
"raw": "\"a\""
}
}
],
"typeArguments": null
}
}
],
"interpreter": null
}