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

1279 lines
30 KiB
JSON

{
"type": "Script",
"span": {
"start": 0,
"end": 567,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 6,
"end": 7,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 0,
"end": 32,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 17,
"end": 30,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 17,
"end": 27,
"ctxt": 0
},
"value": "genericVar",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 27,
"end": 30,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 29,
"end": 30,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 29,
"end": 30,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 7,
"end": 10,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 8,
"end": 9,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 8,
"end": 9,
"ctxt": 0
},
"value": "T",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 42,
"end": 44,
"ctxt": 0
},
"value": "B1",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 33,
"end": 121,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 50,
"end": 121,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 90,
"end": 119,
"ctxt": 0
},
"argument": {
"type": "ClassExpression",
"identifier": null,
"span": {
"start": 97,
"end": 119,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": {
"type": "Identifier",
"span": {
"start": 111,
"end": 112,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 112,
"end": 115,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 113,
"end": 114,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 113,
"end": 114,
"ctxt": 0
},
"value": "U",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 44,
"end": 47,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 45,
"end": 46,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 45,
"end": 46,
"ctxt": 0
},
"value": "U",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 128,
"end": 130,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"declare": false,
"span": {
"start": 122,
"end": 171,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 140,
"end": 169,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 140,
"end": 144,
"ctxt": 0
},
"value": "anon",
"optional": false
},
"value": {
"type": "ClassExpression",
"identifier": null,
"span": {
"start": 147,
"end": 169,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": {
"type": "Identifier",
"span": {
"start": 161,
"end": 162,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 162,
"end": 165,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 163,
"end": 164,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 163,
"end": 164,
"ctxt": 0
},
"value": "V",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
},
"typeAnnotation": null,
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 130,
"end": 133,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 131,
"end": 132,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 131,
"end": 132,
"ctxt": 0
},
"value": "V",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 181,
"end": 183,
"ctxt": 0
},
"value": "B3",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 172,
"end": 240,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 189,
"end": 240,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 195,
"end": 238,
"ctxt": 0
},
"argument": {
"type": "ClassExpression",
"identifier": {
"type": "Identifier",
"span": {
"start": 208,
"end": 213,
"ctxt": 0
},
"value": "Inner",
"optional": false
},
"span": {
"start": 202,
"end": 238,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": {
"type": "Identifier",
"span": {
"start": 230,
"end": 231,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 213,
"end": 221,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 214,
"end": 220,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 214,
"end": 220,
"ctxt": 0
},
"value": "TInner",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 231,
"end": 234,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"value": "W",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 183,
"end": 186,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 184,
"end": 185,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 184,
"end": 185,
"ctxt": 0
},
"value": "W",
"optional": false
},
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 269,
"end": 270,
"ctxt": 0
},
"value": "K",
"optional": false
},
"declare": false,
"span": {
"start": 263,
"end": 314,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 298,
"end": 312,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 298,
"end": 303,
"ctxt": 0
},
"value": "namae",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 303,
"end": 311,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 305,
"end": 311,
"ctxt": 0
},
"kind": "string"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
}
],
"superClass": {
"type": "CallExpression",
"span": {
"start": 279,
"end": 291,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 279,
"end": 281,
"ctxt": 0
},
"value": "B1",
"optional": false
},
"arguments": [],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 281,
"end": 289,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 282,
"end": 288,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 321,
"end": 322,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 315,
"end": 376,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 361,
"end": 374,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 361,
"end": 365,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 365,
"end": 373,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 367,
"end": 373,
"ctxt": 0
},
"kind": "string"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
}
],
"superClass": {
"type": "ParenthesisExpression",
"span": {
"start": 331,
"end": 354,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 332,
"end": 353,
"ctxt": 0
},
"object": {
"type": "NewExpression",
"span": {
"start": 332,
"end": 348,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 336,
"end": 338,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"arguments": [],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 338,
"end": 346,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 339,
"end": 345,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"property": {
"type": "Identifier",
"span": {
"start": 349,
"end": 353,
"ctxt": 0
},
"value": "anon",
"optional": false
}
}
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 377,
"end": 405,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 381,
"end": 404,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 381,
"end": 389,
"ctxt": 0
},
"value": "b3Number",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 392,
"end": 404,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 392,
"end": 394,
"ctxt": 0
},
"value": "B3",
"optional": false
},
"arguments": [],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 394,
"end": 402,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 395,
"end": 401,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"definite": false
}
]
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 412,
"end": 413,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"span": {
"start": 406,
"end": 459,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 445,
"end": 457,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 445,
"end": 448,
"ctxt": 0
},
"value": "nom",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 448,
"end": 456,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 450,
"end": 456,
"ctxt": 0
},
"kind": "string"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
}
],
"superClass": {
"type": "Identifier",
"span": {
"start": 422,
"end": 430,
"ctxt": 0
},
"value": "b3Number",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 430,
"end": 438,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 431,
"end": 437,
"ctxt": 0
},
"kind": "string"
}
]
},
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 460,
"end": 476,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 464,
"end": 475,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 464,
"end": 465,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 468,
"end": 475,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 472,
"end": 473,
"ctxt": 0
},
"value": "C",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 477,
"end": 493,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 481,
"end": 492,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 481,
"end": 482,
"ctxt": 0
},
"value": "k",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 485,
"end": 492,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 489,
"end": 490,
"ctxt": 0
},
"value": "K",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 494,
"end": 510,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 498,
"end": 509,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 498,
"end": 499,
"ctxt": 0
},
"value": "s",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 502,
"end": 509,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 506,
"end": 507,
"ctxt": 0
},
"value": "S",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 511,
"end": 529,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 511,
"end": 528,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 511,
"end": 523,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 511,
"end": 512,
"ctxt": 0
},
"value": "c",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 513,
"end": 523,
"ctxt": 0
},
"value": "genericVar",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 526,
"end": 528,
"ctxt": 0
},
"value": 12.0
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 530,
"end": 548,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 530,
"end": 547,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 530,
"end": 542,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 530,
"end": 531,
"ctxt": 0
},
"value": "k",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 532,
"end": 542,
"ctxt": 0
},
"value": "genericVar",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 545,
"end": 547,
"ctxt": 0
},
"value": 12.0
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 549,
"end": 567,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 549,
"end": 566,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 549,
"end": 561,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 549,
"end": 550,
"ctxt": 0
},
"value": "s",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 551,
"end": 561,
"ctxt": 0
},
"value": "genericVar",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 564,
"end": 566,
"ctxt": 0
},
"value": 12.0
}
}
}
],
"interpreter": null
}