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

1358 lines
36 KiB
JSON

{
"type": "Script",
"span": {
"start": 63,
"end": 752,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 63,
"end": 94,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 73,
"end": 77,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 78,
"end": 94,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 80,
"end": 92,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 80,
"end": 83,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 83,
"end": 91,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 85,
"end": 91,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 95,
"end": 142,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 105,
"end": 112,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 121,
"end": 125,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 121,
"end": 125,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 126,
"end": 142,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 128,
"end": 140,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 128,
"end": 131,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 131,
"end": 139,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 133,
"end": 139,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 143,
"end": 194,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 153,
"end": 161,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [
{
"type": "TsExpressionWithTypeArguments",
"span": {
"start": 170,
"end": 177,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 170,
"end": 177,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeArguments": null
}
],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 178,
"end": 194,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 180,
"end": 192,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 180,
"end": 183,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 183,
"end": 191,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 185,
"end": 191,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 202,
"end": 203,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 196,
"end": 230,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 211,
"end": 220,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 212,
"end": 220,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 214,
"end": 220,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 221,
"end": 227,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 223,
"end": 227,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 223,
"end": 227,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 210,
"end": 228,
"ctxt": 0
}
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 238,
"end": 239,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"span": {
"start": 232,
"end": 285,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 257,
"end": 266,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 258,
"end": 266,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 260,
"end": 266,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 267,
"end": 276,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 269,
"end": 276,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 269,
"end": 276,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 256,
"end": 277,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 248,
"end": 249,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 293,
"end": 295,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"declare": false,
"span": {
"start": 287,
"end": 342,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 313,
"end": 322,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 314,
"end": 322,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 316,
"end": 322,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 323,
"end": 333,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 325,
"end": 333,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 325,
"end": 333,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 312,
"end": 334,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 304,
"end": 305,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "TsModuleDeclaration",
"span": {
"start": 344,
"end": 752,
"ctxt": 0
},
"declare": false,
"global": false,
"id": {
"type": "Identifier",
"span": {
"start": 351,
"end": 359,
"ctxt": 0
},
"value": "Generics",
"optional": false
},
"body": {
"type": "TsModuleBlock",
"span": {
"start": 360,
"end": 752,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 372,
"end": 373,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 366,
"end": 421,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 401,
"end": 410,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 402,
"end": 410,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 404,
"end": 410,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 411,
"end": 414,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 413,
"end": 414,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 413,
"end": 414,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 400,
"end": 415,
"ctxt": 0
}
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 373,
"end": 389,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 374,
"end": 388,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 374,
"end": 375,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 384,
"end": 388,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 384,
"end": 388,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 433,
"end": 434,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"span": {
"start": 427,
"end": 494,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 462,
"end": 471,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 463,
"end": 471,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 465,
"end": 471,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 472,
"end": 481,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 474,
"end": 481,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 474,
"end": 481,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 461,
"end": 482,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 443,
"end": 444,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 444,
"end": 450,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 445,
"end": 449,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 445,
"end": 449,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 506,
"end": 508,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"declare": false,
"span": {
"start": 500,
"end": 569,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 536,
"end": 545,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 537,
"end": 545,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 539,
"end": 545,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 546,
"end": 556,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 548,
"end": 556,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 548,
"end": 556,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 535,
"end": 557,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 517,
"end": 518,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 518,
"end": 524,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 519,
"end": 523,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 519,
"end": 523,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 581,
"end": 583,
"ctxt": 0
},
"value": "B3",
"optional": false
},
"declare": false,
"span": {
"start": 575,
"end": 659,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 624,
"end": 633,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 625,
"end": 633,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 627,
"end": 633,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 634,
"end": 643,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 636,
"end": 643,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 636,
"end": 643,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 623,
"end": 644,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 608,
"end": 609,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 583,
"end": 599,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 584,
"end": 598,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 584,
"end": 585,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 594,
"end": 598,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 594,
"end": 598,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 609,
"end": 612,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 610,
"end": 611,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 610,
"end": 611,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 671,
"end": 673,
"ctxt": 0
},
"value": "B4",
"optional": false
},
"declare": false,
"span": {
"start": 665,
"end": 750,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 714,
"end": 723,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 715,
"end": 723,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 717,
"end": 723,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 724,
"end": 734,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 726,
"end": 734,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 726,
"end": 734,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 713,
"end": 735,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 698,
"end": 699,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 673,
"end": 689,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 674,
"end": 688,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 674,
"end": 675,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 684,
"end": 688,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 684,
"end": 688,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 699,
"end": 702,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 700,
"end": 701,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 700,
"end": 701,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
}
]
}
}
],
"interpreter": null
}