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

1538 lines
41 KiB
JSON

{
"type": "Script",
"span": {
"start": 63,
"end": 861,
"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": 233,
"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": 230,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 223,
"end": 230,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 223,
"end": 230,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 210,
"end": 231,
"ctxt": 0
}
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 241,
"end": 242,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"span": {
"start": 235,
"end": 288,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 260,
"end": 269,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 261,
"end": 269,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 263,
"end": 269,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 270,
"end": 276,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 272,
"end": 276,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 272,
"end": 276,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 259,
"end": 277,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 251,
"end": 252,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 296,
"end": 298,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"declare": false,
"span": {
"start": 290,
"end": 345,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 316,
"end": 325,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 317,
"end": 325,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 319,
"end": 325,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 326,
"end": 336,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 328,
"end": 336,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 328,
"end": 336,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 315,
"end": 337,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 307,
"end": 308,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "TsModuleDeclaration",
"span": {
"start": 347,
"end": 861,
"ctxt": 0
},
"declare": false,
"global": false,
"id": {
"type": "Identifier",
"span": {
"start": 354,
"end": 362,
"ctxt": 0
},
"value": "Generics",
"optional": false
},
"body": {
"type": "TsModuleBlock",
"span": {
"start": 363,
"end": 861,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 375,
"end": 376,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 369,
"end": 427,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 407,
"end": 416,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 408,
"end": 416,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 410,
"end": 416,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 417,
"end": 420,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 419,
"end": 420,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 419,
"end": 420,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 406,
"end": 421,
"ctxt": 0
}
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 376,
"end": 395,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 377,
"end": 394,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 377,
"end": 378,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 387,
"end": 394,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 387,
"end": 394,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 439,
"end": 440,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"span": {
"start": 433,
"end": 503,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 468,
"end": 477,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 469,
"end": 477,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 471,
"end": 477,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 478,
"end": 487,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 480,
"end": 487,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 480,
"end": 487,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 467,
"end": 488,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 449,
"end": 450,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 450,
"end": 456,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 451,
"end": 455,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 451,
"end": 455,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 515,
"end": 517,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"declare": false,
"span": {
"start": 509,
"end": 581,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 548,
"end": 557,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 549,
"end": 557,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 551,
"end": 557,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 558,
"end": 568,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 560,
"end": 568,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 560,
"end": 568,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 547,
"end": 569,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 526,
"end": 527,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 527,
"end": 536,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 528,
"end": 535,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 528,
"end": 535,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 593,
"end": 595,
"ctxt": 0
},
"value": "B3",
"optional": false
},
"declare": false,
"span": {
"start": 587,
"end": 671,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 639,
"end": 648,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 640,
"end": 648,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 642,
"end": 648,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 649,
"end": 655,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 651,
"end": 655,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 651,
"end": 655,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 638,
"end": 656,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 623,
"end": 624,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 595,
"end": 614,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 596,
"end": 613,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 596,
"end": 597,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 606,
"end": 613,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 606,
"end": 613,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 624,
"end": 627,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 625,
"end": 626,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 625,
"end": 626,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 683,
"end": 685,
"ctxt": 0
},
"value": "B4",
"optional": false
},
"declare": false,
"span": {
"start": 677,
"end": 764,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 729,
"end": 738,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 730,
"end": 738,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 732,
"end": 738,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 739,
"end": 748,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 741,
"end": 748,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 741,
"end": 748,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 728,
"end": 749,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 713,
"end": 714,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 685,
"end": 704,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 686,
"end": 703,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 686,
"end": 687,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 696,
"end": 703,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 696,
"end": 703,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 714,
"end": 717,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 715,
"end": 716,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 715,
"end": 716,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 776,
"end": 778,
"ctxt": 0
},
"value": "B5",
"optional": false
},
"declare": false,
"span": {
"start": 770,
"end": 859,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 823,
"end": 832,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 824,
"end": 832,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 826,
"end": 832,
"ctxt": 0
},
"kind": "string"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 833,
"end": 843,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 835,
"end": 843,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 835,
"end": 843,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 822,
"end": 844,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 807,
"end": 808,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 778,
"end": 798,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 779,
"end": 797,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 779,
"end": 780,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 789,
"end": 797,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 789,
"end": 797,
"ctxt": 0
},
"value": "Derived2",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 808,
"end": 811,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 809,
"end": 810,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 809,
"end": 810,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
}
]
}
}
],
"interpreter": null
}