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

896 lines
23 KiB
JSON

{
"type": "Script",
"span": {
"start": 17,
"end": 358,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 23,
"end": 24,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 17,
"end": 109,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 31,
"end": 41,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 31,
"end": 32,
"ctxt": 0
},
"value": "y",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 32,
"end": 40,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 34,
"end": 40,
"ctxt": 0
},
"kind": "number"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
},
{
"type": "Constructor",
"span": {
"start": 46,
"end": 76,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 46,
"end": 57,
"ctxt": 0
},
"value": "constructor",
"optional": false
},
"params": [
{
"type": "Parameter",
"span": {
"start": 58,
"end": 67,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 58,
"end": 67,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 59,
"end": 67,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 61,
"end": 67,
"ctxt": 0
},
"kind": "number"
}
}
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 69,
"end": 76,
"ctxt": 0
},
"stmts": []
},
"accessibility": null,
"isOptional": false
},
{
"type": "ClassMethod",
"span": {
"start": 81,
"end": 93,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 81,
"end": 84,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 85,
"end": 91,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 85,
"end": 91,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 86,
"end": 91,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 88,
"end": 91,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 81,
"end": 93,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 98,
"end": 107,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 98,
"end": 101,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 98,
"end": 107,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 104,
"end": 107,
"ctxt": 0
},
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 117,
"end": 118,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"span": {
"start": 111,
"end": 358,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 125,
"end": 135,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 125,
"end": 126,
"ctxt": 0
},
"value": "y",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 126,
"end": 134,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 128,
"end": 134,
"ctxt": 0
},
"kind": "number"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
},
{
"type": "ClassProperty",
"span": {
"start": 140,
"end": 160,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 140,
"end": 141,
"ctxt": 0
},
"value": "x",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 152,
"end": 159,
"ctxt": 0
},
"value": "hello",
"raw": "\"hello\""
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 141,
"end": 149,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 143,
"end": 149,
"ctxt": 0
},
"kind": "string"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
},
{
"type": "ClassProperty",
"span": {
"start": 165,
"end": 178,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 165,
"end": 169,
"ctxt": 0
},
"value": "_bar",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 169,
"end": 177,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 171,
"end": 177,
"ctxt": 0
},
"kind": "string"
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
},
{
"type": "Constructor",
"span": {
"start": 184,
"end": 257,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 184,
"end": 195,
"ctxt": 0
},
"value": "constructor",
"optional": false
},
"params": [
{
"type": "Parameter",
"span": {
"start": 196,
"end": 205,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 196,
"end": 205,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 197,
"end": 205,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 199,
"end": 205,
"ctxt": 0
},
"kind": "number"
}
}
}
},
{
"type": "Parameter",
"span": {
"start": 207,
"end": 218,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 207,
"end": 218,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 207,
"end": 208,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 211,
"end": 218,
"ctxt": 0
},
"value": "hello",
"raw": "\"hello\""
},
"typeAnnotation": null
}
},
{
"type": "Parameter",
"span": {
"start": 220,
"end": 227,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "RestElement",
"span": {
"start": 220,
"end": 227,
"ctxt": 0
},
"rest": {
"start": 220,
"end": 223,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 223,
"end": 227,
"ctxt": 0
},
"value": "args",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 229,
"end": 257,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 239,
"end": 251,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 239,
"end": 250,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 239,
"end": 245,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 239,
"end": 243,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 244,
"end": 245,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 248,
"end": 250,
"ctxt": 0
},
"value": 10.0,
"raw": "10"
}
}
}
]
},
"accessibility": null,
"isOptional": false
},
{
"type": "ClassMethod",
"span": {
"start": 262,
"end": 283,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 262,
"end": 265,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 266,
"end": 273,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "RestElement",
"span": {
"start": 266,
"end": 273,
"ctxt": 0
},
"rest": {
"start": 266,
"end": 269,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 269,
"end": 273,
"ctxt": 0
},
"value": "args",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
}
],
"decorators": [],
"span": {
"start": 262,
"end": 283,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 274,
"end": 282,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 276,
"end": 282,
"ctxt": 0
},
"kind": "string"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 288,
"end": 355,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 288,
"end": 291,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 292,
"end": 301,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 292,
"end": 301,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 293,
"end": 301,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 295,
"end": 301,
"ctxt": 0
},
"kind": "string"
}
}
}
},
{
"type": "Parameter",
"span": {
"start": 303,
"end": 312,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 303,
"end": 312,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 304,
"end": 312,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 306,
"end": 312,
"ctxt": 0
},
"kind": "number"
}
}
}
}
],
"decorators": [],
"span": {
"start": 288,
"end": 355,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 322,
"end": 355,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 332,
"end": 349,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 339,
"end": 348,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 339,
"end": 343,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 344,
"end": 348,
"ctxt": 0
},
"value": "_bar",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 313,
"end": 321,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 315,
"end": 321,
"ctxt": 0
},
"kind": "string"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}