swc/crates/swc_ecma_parser/tests/tsc/privateNamesAndGenericClasses-2.json

1118 lines
29 KiB
JSON

{
"type": "Script",
"span": {
"start": 35,
"end": 528,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 41,
"end": 42,
"ctxt": 0
},
"value": "C",
"optional": false
},
"declare": false,
"span": {
"start": 35,
"end": 279,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "PrivateProperty",
"span": {
"start": 52,
"end": 60,
"ctxt": 0
},
"key": {
"type": "PrivateName",
"span": {
"start": 52,
"end": 56,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 53,
"end": 56,
"ctxt": 0
},
"value": "foo",
"optional": false
}
},
"value": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 56,
"end": 59,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 58,
"end": 59,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 58,
"end": 59,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isOptional": false,
"isOverride": false,
"readonly": false,
"definite": false
},
{
"type": "PrivateMethod",
"span": {
"start": 65,
"end": 106,
"ctxt": 0
},
"key": {
"type": "PrivateName",
"span": {
"start": 65,
"end": 69,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 66,
"end": 69,
"ctxt": 0
},
"value": "bar",
"optional": false
}
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 65,
"end": 106,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 75,
"end": 106,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 83,
"end": 100,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 90,
"end": 99,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 90,
"end": 94,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 95,
"end": 99,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 96,
"end": 99,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 71,
"end": 74,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 73,
"end": 74,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "Constructor",
"span": {
"start": 111,
"end": 180,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 111,
"end": 122,
"ctxt": 0
},
"value": "constructor",
"optional": false
},
"params": [
{
"type": "Parameter",
"span": {
"start": 123,
"end": 127,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 123,
"end": 127,
"ctxt": 0
},
"value": "t",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 124,
"end": 127,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 126,
"end": 127,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 126,
"end": 127,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 129,
"end": 180,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 137,
"end": 151,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 137,
"end": 150,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 137,
"end": 146,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 137,
"end": 141,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 142,
"end": 146,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 143,
"end": 146,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
},
"right": {
"type": "Identifier",
"span": {
"start": 149,
"end": 150,
"ctxt": 0
},
"value": "t",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 158,
"end": 174,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 158,
"end": 173,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 158,
"end": 159,
"ctxt": 0
},
"value": "t",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "CallExpression",
"span": {
"start": 162,
"end": 173,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 162,
"end": 171,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 162,
"end": 166,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 167,
"end": 171,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 168,
"end": 171,
"ctxt": 0
},
"value": "bar",
"optional": false
}
}
},
"arguments": [],
"typeArguments": null
}
}
}
]
},
"accessibility": null,
"isOptional": false
},
{
"type": "ClassMethod",
"span": {
"start": 185,
"end": 228,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 189,
"end": 192,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 193,
"end": 197,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 193,
"end": 197,
"ctxt": 0
},
"value": "t",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 194,
"end": 197,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 196,
"end": 197,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 196,
"end": 197,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
}
}
],
"decorators": [],
"span": {
"start": 185,
"end": 228,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 199,
"end": 228,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 207,
"end": 221,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 207,
"end": 220,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 207,
"end": 216,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 207,
"end": 211,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 212,
"end": 216,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 213,
"end": 216,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
},
"right": {
"type": "Identifier",
"span": {
"start": 219,
"end": 220,
"ctxt": 0
},
"value": "t",
"optional": false
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
},
"kind": "setter",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 233,
"end": 277,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 237,
"end": 240,
"ctxt": 0
},
"value": "baz",
"optional": false
},
"function": {
"params": [],
"decorators": [],
"span": {
"start": 233,
"end": 277,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 246,
"end": 277,
"ctxt": 0
},
"stmts": [
{
"type": "ReturnStatement",
"span": {
"start": 254,
"end": 271,
"ctxt": 0
},
"argument": {
"type": "MemberExpression",
"span": {
"start": 261,
"end": 270,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 261,
"end": 265,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 266,
"end": 270,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 267,
"end": 270,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 242,
"end": 245,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 244,
"end": 245,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 244,
"end": 245,
"ctxt": 0
},
"value": "T",
"optional": false
},
"typeParams": null
}
}
},
"kind": "getter",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
}
],
"superClass": null,
"isAbstract": false,
"typeParams": {
"type": "TsTypeParameterDeclaration",
"span": {
"start": 42,
"end": 45,
"ctxt": 0
},
"parameters": [
{
"type": "TsTypeParameter",
"span": {
"start": 43,
"end": 44,
"ctxt": 0
},
"name": {
"type": "Identifier",
"span": {
"start": 43,
"end": 44,
"ctxt": 0
},
"value": "T",
"optional": false
},
"in": false,
"out": false,
"constraint": null,
"default": null
}
]
},
"superTypeParams": null,
"implements": []
},
{
"type": "VariableDeclaration",
"span": {
"start": 281,
"end": 298,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 285,
"end": 297,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 285,
"end": 286,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 289,
"end": 297,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 293,
"end": 294,
"ctxt": 0
},
"value": "C",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "NumericLiteral",
"span": {
"start": 295,
"end": 296,
"ctxt": 0
},
"value": 3.0,
"raw": "3"
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 299,
"end": 322,
"ctxt": 0
},
"kind": "let",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 303,
"end": 321,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 303,
"end": 304,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "NewExpression",
"span": {
"start": 307,
"end": 321,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 311,
"end": 312,
"ctxt": 0
},
"value": "C",
"optional": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 313,
"end": 320,
"ctxt": 0
},
"value": "hello",
"raw": "\"hello\""
}
}
],
"typeArguments": null
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 324,
"end": 333,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 324,
"end": 333,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 324,
"end": 329,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 324,
"end": 325,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 326,
"end": 329,
"ctxt": 0
},
"value": "baz",
"optional": false
}
},
"right": {
"type": "NumericLiteral",
"span": {
"start": 332,
"end": 333,
"ctxt": 0
},
"value": 5.0,
"raw": "5"
}
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 372,
"end": 395,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 378,
"end": 395,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 378,
"end": 379,
"ctxt": 0
},
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 379,
"end": 387,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 381,
"end": 387,
"ctxt": 0
},
"kind": "number"
}
}
},
"init": {
"type": "MemberExpression",
"span": {
"start": 390,
"end": 395,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 390,
"end": 391,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 392,
"end": 395,
"ctxt": 0
},
"value": "baz",
"optional": false
}
},
"definite": false
}
]
},
{
"type": "ExpressionStatement",
"span": {
"start": 420,
"end": 427,
"ctxt": 0
},
"expression": {
"type": "MemberExpression",
"span": {
"start": 420,
"end": 426,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 420,
"end": 421,
"ctxt": 0
},
"value": "a",
"optional": false
},
"property": {
"type": "PrivateName",
"span": {
"start": 422,
"end": 426,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 423,
"end": 426,
"ctxt": 0
},
"value": "foo",
"optional": false
}
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 471,
"end": 477,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 471,
"end": 476,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 471,
"end": 472,
"ctxt": 0
},
"value": "a",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 475,
"end": 476,
"ctxt": 0
},
"value": "b",
"optional": false
}
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 522,
"end": 528,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 522,
"end": 527,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "Identifier",
"span": {
"start": 522,
"end": 523,
"ctxt": 0
},
"value": "b",
"optional": false,
"typeAnnotation": null
},
"right": {
"type": "Identifier",
"span": {
"start": 526,
"end": 527,
"ctxt": 0
},
"value": "a",
"optional": false
}
}
}
],
"interpreter": null
}