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

1273 lines
34 KiB
JSON

{
"type": "Script",
"span": {
"start": 15,
"end": 595,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 21,
"end": 22,
"ctxt": 0
},
"value": "D",
"optional": false
},
"declare": false,
"span": {
"start": 15,
"end": 595,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 29,
"end": 42,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 29,
"end": 33,
"ctxt": 0
},
"value": "_bar",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 33,
"end": 41,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 35,
"end": 41,
"ctxt": 0
},
"kind": "string"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
},
{
"type": "ClassMethod",
"span": {
"start": 47,
"end": 56,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 47,
"end": 50,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 47,
"end": 56,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 53,
"end": 56,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 61,
"end": 84,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 61,
"end": 78,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 62,
"end": 77,
"ctxt": 0
},
"value": "computedName1",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 61,
"end": 84,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 81,
"end": 84,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 89,
"end": 121,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 89,
"end": 106,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 90,
"end": 105,
"ctxt": 0
},
"value": "computedName2",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 107,
"end": 116,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 107,
"end": 116,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 108,
"end": 116,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 110,
"end": 116,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 89,
"end": 121,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 118,
"end": 121,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 126,
"end": 176,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 126,
"end": 143,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 127,
"end": 142,
"ctxt": 0
},
"value": "computedName3",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 144,
"end": 153,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 144,
"end": 153,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 145,
"end": 153,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 147,
"end": 153,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 126,
"end": 176,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 163,
"end": 176,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 165,
"end": 174,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 172,
"end": 173,
"ctxt": 0
},
"value": 1.0
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 154,
"end": 162,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 156,
"end": 162,
"ctxt": 0
},
"kind": "number"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 181,
"end": 228,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 181,
"end": 184,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 181,
"end": 228,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 195,
"end": 228,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 205,
"end": 222,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 212,
"end": 221,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 212,
"end": 216,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 217,
"end": 221,
"ctxt": 0
},
"value": "_bar",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 186,
"end": 194,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 188,
"end": 194,
"ctxt": 0
},
"kind": "string"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 234,
"end": 296,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 234,
"end": 237,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 238,
"end": 244,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 238,
"end": 244,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 239,
"end": 244,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 241,
"end": 244,
"ctxt": 0
},
"kind": "any"
}
}
}
},
{
"type": "Parameter",
"span": {
"start": 246,
"end": 255,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 246,
"end": 255,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 247,
"end": 255,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 249,
"end": 255,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 234,
"end": 296,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 265,
"end": 296,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 275,
"end": 290,
"ctxt": 0
},
"argument": {
"type": "StringLiteral",
"span": {
"start": 282,
"end": 289,
"ctxt": 0
},
"value": "HELLO",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 256,
"end": 264,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 258,
"end": 264,
"ctxt": 0
},
"kind": "string"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 301,
"end": 331,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 308,
"end": 325,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 309,
"end": 324,
"ctxt": 0
},
"value": "computedname4",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 301,
"end": 331,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 328,
"end": 331,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 336,
"end": 375,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 343,
"end": 360,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 344,
"end": 359,
"ctxt": 0
},
"value": "computedname5",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 361,
"end": 370,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 361,
"end": 370,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 362,
"end": 370,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 364,
"end": 370,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 336,
"end": 375,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 372,
"end": 375,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 380,
"end": 441,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 387,
"end": 404,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 388,
"end": 403,
"ctxt": 0
},
"value": "computedname6",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 405,
"end": 414,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 405,
"end": 414,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 406,
"end": 414,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 408,
"end": 414,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 380,
"end": 441,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 425,
"end": 441,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 427,
"end": 439,
"ctxt": 0
},
"argument": {
"type": "BooleanLiteral",
"span": {
"start": 434,
"end": 438,
"ctxt": 0
},
"value": true
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 415,
"end": 424,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 417,
"end": 424,
"ctxt": 0
},
"kind": "boolean"
}
}
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 446,
"end": 515,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 453,
"end": 465,
"ctxt": 0
},
"value": "staticMethod",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 446,
"end": 515,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 468,
"end": 515,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 478,
"end": 492,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 482,
"end": 491,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 482,
"end": 483,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "BinaryExpression",
"span": {
"start": 486,
"end": 491,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "NumericLiteral",
"span": {
"start": 486,
"end": 487,
"ctxt": 0
},
"value": 1.0
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 490,
"end": 491,
"ctxt": 0
},
"value": 2.0
}
},
"definite": false
}
]
},
{
"type": "ReturnStatement",
"span": {
"start": 501,
"end": 509,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 508,
"end": 509,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 520,
"end": 545,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 527,
"end": 530,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 531,
"end": 540,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 531,
"end": 540,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 532,
"end": 540,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 534,
"end": 540,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 520,
"end": 545,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 542,
"end": 545,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 550,
"end": 593,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 557,
"end": 560,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 561,
"end": 570,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 561,
"end": 570,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 562,
"end": 570,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 564,
"end": 570,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 550,
"end": 593,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 580,
"end": 593,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 582,
"end": 591,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 589,
"end": 590,
"ctxt": 0
},
"value": 1.0
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 571,
"end": 579,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 573,
"end": 579,
"ctxt": 0
},
"kind": "number"
}
}
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}