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

916 lines
24 KiB
JSON

{
"type": "Script",
"span": {
"start": 63,
"end": 541,
"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": "number"
}
}
}
],
"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": 290,
"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": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 270,
"end": 278,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 272,
"end": 278,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 259,
"end": 279,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 251,
"end": 252,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "TsModuleDeclaration",
"span": {
"start": 292,
"end": 541,
"ctxt": 0
},
"declare": false,
"global": false,
"id": {
"type": "Identifier",
"span": {
"start": 299,
"end": 307,
"ctxt": 0
},
"value": "Generics",
"optional": false
},
"body": {
"type": "TsModuleBlock",
"span": {
"start": 308,
"end": 541,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 320,
"end": 321,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 314,
"end": 372,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 352,
"end": 361,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 353,
"end": 361,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 355,
"end": 361,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 362,
"end": 365,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 364,
"end": 365,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 364,
"end": 365,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"readonly": false,
"static": false,
"span": {
"start": 351,
"end": 366,
"ctxt": 0
}
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 321,
"end": 340,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 322,
"end": 339,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 322,
"end": 323,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 332,
"end": 339,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 332,
"end": 339,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 384,
"end": 385,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"span": {
"start": 378,
"end": 447,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 413,
"end": 422,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 414,
"end": 422,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 416,
"end": 422,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 423,
"end": 431,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 425,
"end": 431,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 412,
"end": 432,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 394,
"end": 395,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 395,
"end": 401,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 396,
"end": 400,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 396,
"end": 400,
"ctxt": 0
},
"value": "Base",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 459,
"end": 461,
"ctxt": 0
},
"value": "B3",
"optional": false
},
"declare": false,
"span": {
"start": 453,
"end": 539,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "TsIndexSignature",
"params": [
{
"type": "Identifier",
"span": {
"start": 505,
"end": 514,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 506,
"end": 514,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 508,
"end": 514,
"ctxt": 0
},
"kind": "number"
}
}
}
],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 515,
"end": 523,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 517,
"end": 523,
"ctxt": 0
},
"kind": "string"
}
},
"readonly": false,
"static": false,
"span": {
"start": 504,
"end": 524,
"ctxt": 0
}
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 489,
"end": 490,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 461,
"end": 480,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 462,
"end": 479,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 462,
"end": 463,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": {
"type": "TsTypeReference",
"span": {
"start": 472,
"end": 479,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 472,
"end": 479,
"ctxt": 0
},
"value": "Derived",
"optional": false
},
"typeParams": null
},
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 490,
"end": 493,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 491,
"end": 492,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 491,
"end": 492,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
}
]
}
}
],
"interpreter": null
}