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

1297 lines
30 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 1,
"end": 568,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 1,
"end": 33,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 18,
"end": 31,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 18,
"end": 28,
"ctxt": 0
},
"value": "genericVar",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 28,
"end": 31,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 30,
"end": 31,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 30,
"end": 31,
"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": 8,
"end": 11,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 9,
"end": 10,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 9,
"end": 10,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 43,
"end": 45,
"ctxt": 0
},
"value": "B1",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 34,
"end": 122,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 51,
"end": 122,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 91,
"end": 120,
"ctxt": 0
},
"argument": {
"type": "ClassExpression",
"identifier": null,
"span": {
"start": 98,
"end": 120,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": {
"type": "Identifier",
"span": {
"start": 112,
"end": 113,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 113,
"end": 116,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 114,
"end": 115,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 114,
"end": 115,
"ctxt": 0
},
"value": "U",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 45,
"end": 48,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 46,
"end": 47,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 46,
"end": 47,
"ctxt": 0
},
"value": "U",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 129,
"end": 131,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"declare": false,
"span": {
"start": 123,
"end": 172,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 141,
"end": 170,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 141,
"end": 145,
"ctxt": 0
},
"value": "anon",
"optional": false
},
"value": {
"type": "ClassExpression",
"identifier": null,
"span": {
"start": 148,
"end": 170,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": {
"type": "Identifier",
"span": {
"start": 162,
"end": 163,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 163,
"end": 166,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 164,
"end": 165,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 164,
"end": 165,
"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": 131,
"end": 134,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 132,
"end": 133,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 132,
"end": 133,
"ctxt": 0
},
"value": "V",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 182,
"end": 184,
"ctxt": 0
},
"value": "B3",
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 173,
"end": 241,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 190,
"end": 241,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 196,
"end": 239,
"ctxt": 0
},
"argument": {
"type": "ClassExpression",
"identifier": {
"type": "Identifier",
"span": {
"start": 209,
"end": 214,
"ctxt": 0
},
"value": "Inner",
"optional": false
},
"span": {
"start": 203,
"end": 239,
"ctxt": 0
},
"decorators": [],
"body": [],
"superClass": {
"type": "Identifier",
"span": {
"start": 231,
"end": 232,
"ctxt": 0
},
"value": "A",
"optional": false
},
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 214,
"end": 222,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 215,
"end": 221,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 215,
"end": 221,
"ctxt": 0
},
"value": "TInner",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 232,
"end": 235,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 233,
"end": 234,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 233,
"end": 234,
"ctxt": 0
},
"value": "W",
"optional": false
},
"typeParams": null
}
]
},
"implements": []
}
}
]
},
"generator": false,
"async": false,
"typeParameters": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 184,
"end": 187,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 185,
"end": 186,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 185,
"end": 186,
"ctxt": 0
},
"value": "W",
"optional": false
},
"in": false,
"out": false,
"const": false,
"constraint": null,
"default": null
}
]
},
"returnType": null
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 270,
"end": 271,
"ctxt": 0
},
"value": "K",
"optional": false
},
"declare": false,
"span": {
"start": 264,
"end": 315,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 299,
"end": 313,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 299,
"end": 304,
"ctxt": 0
},
"value": "namae",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 304,
"end": 312,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 306,
"end": 312,
"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": 280,
"end": 292,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 280,
"end": 282,
"ctxt": 0
},
"value": "B1",
"optional": false
},
"arguments": [],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 282,
"end": 290,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 283,
"end": 289,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 322,
"end": 323,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 316,
"end": 377,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 362,
"end": 375,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 362,
"end": 366,
"ctxt": 0
},
"value": "name",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 366,
"end": 374,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 368,
"end": 374,
"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": 332,
"end": 355,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 333,
"end": 354,
"ctxt": 0
},
"object": {
"type": "NewExpression",
"span": {
"start": 333,
"end": 349,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 337,
"end": 339,
"ctxt": 0
},
"value": "B2",
"optional": false
},
"arguments": [],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 339,
"end": 347,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 340,
"end": 346,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"property": {
"type": "Identifier",
"span": {
"start": 350,
"end": 354,
"ctxt": 0
},
"value": "anon",
"optional": false
}
}
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 378,
"end": 406,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 382,
"end": 405,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 382,
"end": 390,
"ctxt": 0
},
"value": "b3Number",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "CallExpression",
"span": {
"start": 393,
"end": 405,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 393,
"end": 395,
"ctxt": 0
},
"value": "B3",
"optional": false
},
"arguments": [],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 395,
"end": 403,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 396,
"end": 402,
"ctxt": 0
},
"kind": "number"
}
]
}
},
"definite": false
}
]
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 413,
"end": 414,
"ctxt": 0
},
"value": "S",
"optional": false
},
"declare": false,
"span": {
"start": 407,
"end": 460,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 446,
"end": 458,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 446,
"end": 449,
"ctxt": 0
},
"value": "nom",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 449,
"end": 457,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 451,
"end": 457,
"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": 423,
"end": 431,
"ctxt": 0
},
"value": "b3Number",
"optional": false
},
"isAbstract": false,
"typeParams": null,
"superTypeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 431,
"end": 439,
"ctxt": 0
},
"params": [
{
"type": "TsKeywordType",
"span": {
"start": 432,
"end": 438,
"ctxt": 0
},
"kind": "string"
}
]
},
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 461,
"end": 477,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 465,
"end": 476,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 465,
"end": 466,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 469,
"end": 476,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 473,
"end": 474,
"ctxt": 0
},
"value": "C",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 478,
"end": 494,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 482,
"end": 493,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 482,
"end": 483,
"ctxt": 0
},
"value": "k",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 486,
"end": 493,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 490,
"end": 491,
"ctxt": 0
},
"value": "K",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 495,
"end": 511,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 499,
"end": 510,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 499,
"end": 500,
"ctxt": 0
},
"value": "s",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 503,
"end": 510,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 507,
"end": 508,
"ctxt": 0
},
"value": "S",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 512,
"end": 530,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 512,
"end": 529,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 512,
"end": 524,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 512,
"end": 513,
"ctxt": 0
},
"value": "c",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 514,
"end": 524,
"ctxt": 0
},
"value": "genericVar",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 527,
"end": 529,
"ctxt": 0
},
"value": 12.0,
"raw": "12"
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 531,
"end": 549,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 531,
"end": 548,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 531,
"end": 543,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 531,
"end": 532,
"ctxt": 0
},
"value": "k",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 533,
"end": 543,
"ctxt": 0
},
"value": "genericVar",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 546,
"end": 548,
"ctxt": 0
},
"value": 12.0,
"raw": "12"
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 550,
"end": 568,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 550,
"end": 567,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 550,
"end": 562,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 550,
"end": 551,
"ctxt": 0
},
"value": "s",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 552,
"end": 562,
"ctxt": 0
},
"value": "genericVar",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 565,
"end": 567,
"ctxt": 0
},
"value": 12.0,
"raw": "12"
}
}
}
],
"interpreter": null
}