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

675 lines
17 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 242,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 7,
"end": 8,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 1,
"end": 23,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "ClassProperty",
"span": {
"start": 15,
"end": 21,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 15,
"end": 16,
"ctxt": 0
},
"value": "x",
"optional": false
},
"value": {
"type": "NumericLiteral",
"span": {
"start": 19,
"end": 20,
"ctxt": 0
},
"value": 1.0,
"raw": "1"
},
"typeAnnotation": null,
"isStatic": false,
"decorators": [],
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": false,
"declare": false,
"definite": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": null,
"superTypeParams": null,
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 25,
"end": 41,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 29,
"end": 40,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 29,
"end": 30,
"ctxt": 0
},
"value": "c",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 33,
"end": 40,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 37,
"end": 38,
"ctxt": 0
},
"value": "C",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 42,
"end": 50,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 42,
"end": 49,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 42,
"end": 45,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 42,
"end": 43,
"ctxt": 0
},
"value": "c",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 44,
"end": 45,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 48,
"end": 49,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 51,
"end": 68,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 55,
"end": 67,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 55,
"end": 57,
"ctxt": 0
},
"value": "c2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 60,
"end": 67,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 64,
"end": 65,
"ctxt": 0
},
"value": "C",
"optional": false
},
"arguments": [],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 69,
"end": 90,
"ctxt": 0
},
"kind": "var",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 73,
"end": 89,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"value": "r",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "BinaryExpression",
"span": {
"start": 77,
"end": 89,
"ctxt": 0
},
"operator": "===",
"left": {
"type": "MemberExpression",
"span": {
"start": 77,
"end": 80,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 77,
"end": 78,
"ctxt": 0
},
"value": "c",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 79,
"end": 80,
"ctxt": 0
},
"value": "x",
"optional": false
}
},
"right": {
"type": "MemberExpression",
"span": {
"start": 85,
"end": 89,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 85,
"end": 87,
"ctxt": 0
},
"value": "c2",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 88,
"end": 89,
"ctxt": 0
},
"value": "x",
"optional": false
}
}
},
"definite": false
}
]
},
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 111,
"end": 116,
"ctxt": 0
},
"value": "MyMap",
"optional": false
},
"declare": false,
"span": {
"start": 105,
"end": 242,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "Constructor",
"span": {
"start": 129,
"end": 188,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 129,
"end": 140,
"ctxt": 0
},
"value": "constructor",
"optional": false
},
"params": [
{
"type": "TsParameterProperty",
"span": {
"start": 141,
"end": 184,
"ctxt": 0
},
"decorators": [],
"accessibility": "private",
"override": false,
"readonly": true,
"param": {
"type": "Identifier",
"span": {
"start": 158,
"end": 184,
"ctxt": 0
},
"value": "Map_",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 162,
"end": 184,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 164,
"end": 184,
"ctxt": 0
},
"members": [
{
"type": "TsConstructSignatureDeclaration",
"span": {
"start": 166,
"end": 182,
"ctxt": 0
},
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 177,
"end": 182,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 179,
"end": 182,
"ctxt": 0
},
"kind": "any"
}
},
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 169,
"end": 175,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 170,
"end": 171,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 170,
"end": 171,
"ctxt": 0
},
"value": "K",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
},
{
"type": "TsTypeParameter",
"span": {
"start": 173,
"end": 174,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 173,
"end": 174,
"ctxt": 0
},
"value": "V",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
}
}
]
}
}
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 186,
"end": 188,
"ctxt": 0
},
"stmts": []
},
"accessibility": null,
"isOptional": false
},
{
"type": "ClassProperty",
"span": {
"start": 193,
"end": 240,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 210,
"end": 215,
"ctxt": 0
},
"value": "store",
"optional": false
},
"value": {
"type": "NewExpression",
"span": {
"start": 218,
"end": 239,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 222,
"end": 231,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 222,
"end": 226,
"ctxt": 0
}
},
"property": {
"type": "Identifier",
"span": {
"start": 227,
"end": 231,
"ctxt": 0
},
"value": "Map_",
"optional": false
}
},
"arguments": [],
"typeArguments": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 231,
"end": 237,
"ctxt": 0
},
"params": [
{
"type": "TsTypeReference",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 232,
"end": 233,
"ctxt": 0
},
"value": "K",
"optional": false
},
"typeParams": null
},
{
"type": "TsTypeReference",
"span": {
"start": 235,
"end": 236,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 235,
"end": 236,
"ctxt": 0
},
"value": "V",
"optional": false
},
"typeParams": null
}
]
}
},
"typeAnnotation": null,
"isStatic": false,
"decorators": [],
"accessibility": "private",
"isAbstract": false,
"isOptional": false,
"isOverride": false,
"readonly": true,
"declare": false,
"definite": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 116,
"end": 122,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 117,
"end": 118,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 117,
"end": 118,
"ctxt": 0
},
"value": "K",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
},
{
"type": "TsTypeParameter",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 120,
"end": 121,
"ctxt": 0
},
"value": "V",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"superTypeParams": null,
"implements": []
}
],
"interpreter": null
}