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

903 lines
23 KiB
JSON

{
"type": "Script",
"span": {
"start": 16,
"end": 357,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 22,
"end": 23,
"ctxt": 0
},
"value": "A",
"optional": false
},
"declare": false,
"span": {
"start": 16,
"end": 108,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 30,
"end": 40,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 30,
"end": 31,
"ctxt": 0
},
"value": "y",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 31,
"end": 39,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 33,
"end": 39,
"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": 45,
"end": 75,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 45,
"end": 56,
"ctxt": 0
},
"value": "constructor",
"optional": false
},
"params": [
{
"type": "Parameter",
"span": {
"start": 57,
"end": 66,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 57,
"end": 66,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 58,
"end": 66,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 60,
"end": 66,
"ctxt": 0
},
"kind": "number"
}
}
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 68,
"end": 75,
"ctxt": 0
},
"stmts": []
},
"accessibility": null,
"isOptional": false
},
{
"type": "ClassMethod",
"span": {
"start": 80,
"end": 92,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 80,
"end": 83,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 84,
"end": 90,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 84,
"end": 90,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 85,
"end": 90,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 87,
"end": 90,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 80,
"end": 92,
"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": 97,
"end": 106,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 97,
"end": 100,
"ctxt": 0
},
"value": "foo",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 97,
"end": 106,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 103,
"end": 106,
"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": 116,
"end": 117,
"ctxt": 0
},
"value": "B",
"optional": false
},
"declare": false,
"span": {
"start": 110,
"end": 357,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 124,
"end": 134,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 124,
"end": 125,
"ctxt": 0
},
"value": "y",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 125,
"end": 133,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 127,
"end": 133,
"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": 139,
"end": 159,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 139,
"end": 140,
"ctxt": 0
},
"value": "x",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 151,
"end": 158,
"ctxt": 0
},
"value": "hello",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 140,
"end": 148,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 142,
"end": 148,
"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": 164,
"end": 177,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 164,
"end": 168,
"ctxt": 0
},
"value": "_bar",
"optional": false
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 168,
"end": 176,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 170,
"end": 176,
"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": 183,
"end": 256,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 183,
"end": 194,
"ctxt": 0
},
"value": "constructor",
"optional": false
},
"params": [
{
"type": "Parameter",
"span": {
"start": 195,
"end": 204,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 195,
"end": 204,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 196,
"end": 204,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 198,
"end": 204,
"ctxt": 0
},
"kind": "number"
}
}
}
},
{
"type": "Parameter",
"span": {
"start": 206,
"end": 217,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "AssignmentPattern",
"span": {
"start": 206,
"end": 217,
"ctxt": 0
},
"left": {
"type": "Identifier",
"span": {
"start": 206,
"end": 207,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "StringLiteral",
"span": {
"start": 210,
"end": 217,
"ctxt": 0
},
"value": "hello",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
},
"typeAnnotation": null
}
},
{
"type": "Parameter",
"span": {
"start": 219,
"end": 226,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "RestElement",
"span": {
"start": 219,
"end": 226,
"ctxt": 0
},
"rest": {
"start": 219,
"end": 222,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 222,
"end": 226,
"ctxt": 0
},
"value": "args",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 228,
"end": 256,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 238,
"end": 250,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 238,
"end": 249,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 238,
"end": 244,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 238,
"end": 242,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 243,
"end": 244,
"ctxt": 0
},
"value": "y",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 247,
"end": 249,
"ctxt": 0
},
"value": 10.0
}
}
}
]
},
"accessibility": null,
"isOptional": false
},
{
"type": "ClassMethod",
"span": {
"start": 261,
"end": 282,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 261,
"end": 264,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 265,
"end": 272,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "RestElement",
"span": {
"start": 265,
"end": 272,
"ctxt": 0
},
"rest": {
"start": 265,
"end": 268,
"ctxt": 0
},
"argument": {
"type": "Identifier",
"span": {
"start": 268,
"end": 272,
"ctxt": 0
},
"value": "args",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": null
}
}
],
"decorators": [],
"span": {
"start": 261,
"end": 282,
"ctxt": 0
},
"body": null,
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 273,
"end": 281,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 275,
"end": 281,
"ctxt": 0
},
"kind": "string"
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 287,
"end": 354,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 287,
"end": 290,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 291,
"end": 300,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 291,
"end": 300,
"ctxt": 0
},
"value": "z",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 292,
"end": 300,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 294,
"end": 300,
"ctxt": 0
},
"kind": "string"
}
}
}
},
{
"type": "Parameter",
"span": {
"start": 302,
"end": 311,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 302,
"end": 311,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 303,
"end": 311,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 305,
"end": 311,
"ctxt": 0
},
"kind": "number"
}
}
}
}
],
"decorators": [],
"span": {
"start": 287,
"end": 354,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 321,
"end": 354,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 331,
"end": 348,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 338,
"end": 347,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 338,
"end": 342,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 343,
"end": 347,
"ctxt": 0
},
"value": "_bar",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 312,
"end": 320,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 314,
"end": 320,
"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
}