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

1249 lines
33 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 16,
"end": 596,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 22,
"end": 23,
"ctxt": 0
},
"value": "D",
"optional": false
},
"declare": false,
"span": {
"start": 16,
"end": 596,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 30,
"end": 43,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 30,
"end": 34,
"ctxt": 0
},
"value": "_bar",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 34,
"end": 42,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 36,
"end": 42,
"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": 48,
"end": 57,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 48,
"end": 51,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 48,
"end": 57,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 54,
"end": 57,
"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": 62,
"end": 85,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 62,
"end": 79,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 63,
"end": 78,
"ctxt": 0
},
"value": "computedName1",
"raw": "\"computedName1\""
}
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 62,
"end": 85,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 82,
"end": 85,
"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": 90,
"end": 122,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 90,
"end": 107,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 91,
"end": 106,
"ctxt": 0
},
"value": "computedName2",
"raw": "\"computedName2\""
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 108,
"end": 117,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 108,
"end": 117,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 109,
"end": 117,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 111,
"end": 117,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 90,
"end": 122,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 119,
"end": 122,
"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": 127,
"end": 177,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 127,
"end": 144,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 128,
"end": 143,
"ctxt": 0
},
"value": "computedName3",
"raw": "\"computedName3\""
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 145,
"end": 154,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 145,
"end": 154,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 146,
"end": 154,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 148,
"end": 154,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 127,
"end": 177,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 164,
"end": 177,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 166,
"end": 175,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 173,
"end": 174,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 155,
"end": 163,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 157,
"end": 163,
"ctxt": 0
},
"kind": "number"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 182,
"end": 229,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 182,
"end": 185,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 182,
"end": 229,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 196,
"end": 229,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 206,
"end": 223,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 213,
"end": 222,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 213,
"end": 217,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 218,
"end": 222,
"ctxt": 0
},
"value": "_bar",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 187,
"end": 195,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 189,
"end": 195,
"ctxt": 0
},
"kind": "string"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 235,
"end": 297,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 235,
"end": 238,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 239,
"end": 245,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 239,
"end": 245,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 240,
"end": 245,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 242,
"end": 245,
"ctxt": 0
},
"kind": "any"
}
}
}
},
{
"type": "Parameter",
"span": {
"start": 247,
"end": 256,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 247,
"end": 256,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 248,
"end": 256,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 250,
"end": 256,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 235,
"end": 297,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 266,
"end": 297,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 276,
"end": 291,
"ctxt": 0
},
"argument": {
"type": "StringLiteral",
"span": {
"start": 283,
"end": 290,
"ctxt": 0
},
"value": "HELLO",
"raw": "\"HELLO\""
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 257,
"end": 265,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 259,
"end": 265,
"ctxt": 0
},
"kind": "string"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 302,
"end": 332,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 309,
"end": 326,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 310,
"end": 325,
"ctxt": 0
},
"value": "computedname4",
"raw": "\"computedname4\""
}
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 302,
"end": 332,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 329,
"end": 332,
"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": 337,
"end": 376,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 344,
"end": 361,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 345,
"end": 360,
"ctxt": 0
},
"value": "computedname5",
"raw": "\"computedname5\""
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 362,
"end": 371,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 362,
"end": 371,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 363,
"end": 371,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 365,
"end": 371,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 337,
"end": 376,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 373,
"end": 376,
"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": 381,
"end": 442,
"ctxt": 0
},
"key": {
"type": "Computed",
"span": {
"start": 388,
"end": 405,
"ctxt": 0
},
"expression": {
"type": "StringLiteral",
"span": {
"start": 389,
"end": 404,
"ctxt": 0
},
"value": "computedname6",
"raw": "\"computedname6\""
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 406,
"end": 415,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 406,
"end": 415,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 407,
"end": 415,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 409,
"end": 415,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 381,
"end": 442,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 426,
"end": 442,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 428,
"end": 440,
"ctxt": 0
},
"argument": {
"type": "BooleanLiteral",
"span": {
"start": 435,
"end": 439,
"ctxt": 0
},
"value": true
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 416,
"end": 425,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 418,
"end": 425,
"ctxt": 0
},
"kind": "boolean"
}
}
},
"kind": "method",
"isStatic": true,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 447,
"end": 516,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 454,
"end": 466,
"ctxt": 0
},
"value": "staticMethod",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 447,
"end": 516,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 469,
"end": 516,
"ctxt": 0
},
"stmts": [
{
"type": "VariableDeclaration",
"span": {
"start": 479,
"end": 493,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 483,
"end": 492,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 483,
"end": 484,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "BinaryExpression",
"span": {
"start": 487,
"end": 492,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "NumericLiteral",
"span": {
"start": 487,
"end": 488,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 491,
"end": 492,
"ctxt": 0
},
"value": 2.0,
"raw": "2"
}
},
"definite": false
}
]
},
{
"type": "ReturnStatement",
"span": {
"start": 502,
"end": 510,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 509,
"end": 510,
"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": 521,
"end": 546,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 528,
"end": 531,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 532,
"end": 541,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 532,
"end": 541,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 533,
"end": 541,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 535,
"end": 541,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 521,
"end": 546,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 543,
"end": 546,
"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": 551,
"end": 594,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 558,
"end": 561,
"ctxt": 0
},
"value": "bar",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 562,
"end": 571,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 562,
"end": 571,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 563,
"end": 571,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 565,
"end": 571,
"ctxt": 0
},
"kind": "string"
}
}
}
}
],
"decorators": [],
"span": {
"start": 551,
"end": 594,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 581,
"end": 594,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 583,
"end": 592,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 590,
"end": 591,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 572,
"end": 580,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 574,
"end": 580,
"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
}