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

650 lines
18 KiB
JSON

{
"type": "Script",
"span": {
"start": 41,
"end": 309,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 41,
"end": 143,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 51,
"end": 56,
"ctxt": 0
},
"value": "Array",
"optional": false
},
"declare": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 56,
"end": 59,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 57,
"end": 58,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 57,
"end": 58,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 60,
"end": 143,
"ctxt": 0
},
"body": [
{
"type": "TsMethodSignature",
"span": {
"start": 66,
"end": 141,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 66,
"end": 79,
"ctxt": 0
},
"value": "equalsShallow",
"optional": false
},
"computed": false,
"optional": false,
"params": [
{
"type": "Identifier",
"span": {
"start": 83,
"end": 105,
"ctxt": 0
},
"value": "this",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 87,
"end": 105,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 89,
"end": 105,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 89,
"end": 102,
"ctxt": 0
},
"value": "ReadonlyArray",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 102,
"end": 105,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 103,
"end": 104,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 103,
"end": 104,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
}
}
}
},
{
"type": "Identifier",
"span": {
"start": 107,
"end": 130,
"ctxt": 0
},
"value": "other",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 112,
"end": 130,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 114,
"end": 130,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 114,
"end": 127,
"ctxt": 0
},
"value": "ReadonlyArray",
"optional": false
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 127,
"end": 130,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 128,
"end": 129,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 128,
"end": 129,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
}
}
}
}
],
"typeAnn": {
"type": "TsTypeAnnotation",
"span": {
"start": 131,
"end": 140,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 133,
"end": 140,
"ctxt": 0
},
"kind": "boolean"
}
},
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 79,
"end": 82,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 80,
"end": 81,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 80,
"end": 81,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
}
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 145,
"end": 212,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 159,
"end": 211,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 159,
"end": 160,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 160,
"end": 211,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 162,
"end": 211,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 162,
"end": 181,
"ctxt": 0
},
"elemType": {
"type": "TsParenthesizedType",
"span": {
"start": 162,
"end": 179,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 163,
"end": 178,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 163,
"end": 169,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 172,
"end": 178,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
{
"type": "TsArrayType",
"span": {
"start": 184,
"end": 190,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 184,
"end": 188,
"ctxt": 0
},
"kind": "null"
}
},
{
"type": "TsArrayType",
"span": {
"start": 193,
"end": 204,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 193,
"end": 202,
"ctxt": 0
},
"kind": "undefined"
}
},
{
"type": "TsArrayType",
"span": {
"start": 207,
"end": 211,
"ctxt": 0
},
"elemType": {
"type": "TsTypeLiteral",
"span": {
"start": 207,
"end": 209,
"ctxt": 0
},
"members": []
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 213,
"end": 280,
"ctxt": 0
},
"kind": "const",
"declare": true,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 227,
"end": 279,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 227,
"end": 228,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 228,
"end": 279,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 230,
"end": 279,
"ctxt": 0
},
"types": [
{
"type": "TsArrayType",
"span": {
"start": 230,
"end": 249,
"ctxt": 0
},
"elemType": {
"type": "TsParenthesizedType",
"span": {
"start": 230,
"end": 247,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsUnionType",
"span": {
"start": 231,
"end": 246,
"ctxt": 0
},
"types": [
{
"type": "TsKeywordType",
"span": {
"start": 231,
"end": 237,
"ctxt": 0
},
"kind": "string"
},
{
"type": "TsKeywordType",
"span": {
"start": 240,
"end": 246,
"ctxt": 0
},
"kind": "number"
}
]
}
}
},
{
"type": "TsArrayType",
"span": {
"start": 252,
"end": 258,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 252,
"end": 256,
"ctxt": 0
},
"kind": "null"
}
},
{
"type": "TsArrayType",
"span": {
"start": 261,
"end": 272,
"ctxt": 0
},
"elemType": {
"type": "TsKeywordType",
"span": {
"start": 261,
"end": 270,
"ctxt": 0
},
"kind": "undefined"
}
},
{
"type": "TsArrayType",
"span": {
"start": 275,
"end": 279,
"ctxt": 0
},
"elemType": {
"type": "TsTypeLiteral",
"span": {
"start": 275,
"end": 277,
"ctxt": 0
},
"members": []
}
}
]
}
}
},
"init": null,
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 282,
"end": 309,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 286,
"end": 308,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 286,
"end": 287,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 290,
"end": 308,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 290,
"end": 305,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 290,
"end": 291,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 292,
"end": 305,
"ctxt": 0
},
"value": "equalsShallow",
"optional": false
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 306,
"end": 307,
"ctxt": 0
},
"value": "b",
"optional": false
}
}
],
"typeArguments": null
},
"definite": false
}
]
}
],
"interpreter": null
}