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

872 lines
25 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 80,
"end": 486,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 86,
"end": 89,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"declare": false,
"span": {
"start": 80,
"end": 288,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "PrivateProperty",
"span": {
"start": 96,
"end": 227,
"ctxt": 0
},
"key": {
"type": "PrivateName",
"span": {
"start": 96,
"end": 99,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 97,
"end": 99,
"ctxt": 0
},
"value": "p1",
"optional": false
}
},
"value": {
"type": "ArrowFunctionExpression",
"span": {
"start": 135,
"end": 227,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 136,
"end": 137,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 142,
"end": 227,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 152,
"end": 221,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 156,
"end": 177,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 156,
"end": 164,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 163,
"end": 164,
"ctxt": 0
},
"value": "v",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 169,
"end": 177,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 179,
"end": 221,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 193,
"end": 211,
"ctxt": 0
},
"argument": {
"type": "NewExpression",
"span": {
"start": 199,
"end": 210,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 203,
"end": 208,
"ctxt": 0
},
"value": "Error",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 99,
"end": 132,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 101,
"end": 132,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 102,
"end": 108,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 103,
"end": 108,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 105,
"end": 108,
"ctxt": 0
},
"kind": "any"
}
}
}
],
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 110,
"end": 132,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 113,
"end": 132,
"ctxt": 0
},
"asserts": true,
"paramName": {
"type": "Identifier",
"span": {
"start": 121,
"end": 122,
"ctxt": 0
},
"value": "v",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 126,
"end": 132,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 126,
"end": 132,
"ctxt": 0
},
"kind": "string"
}
}
}
}
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isOptional": false,
"isOverride": false,
"readonly": false
},
{
"type": "ClassMethod",
"span": {
"start": 232,
"end": 286,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 232,
"end": 234,
"ctxt": 0
},
"value": "m1",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 235,
"end": 245,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 235,
"end": 245,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 236,
"end": 245,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 238,
"end": 245,
"ctxt": 0
},
"kind": "unknown"
}
}
}
}
],
"decorators": [],
"span": {
"start": 232,
"end": 286,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 247,
"end": 286,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 257,
"end": 269,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 257,
"end": 268,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 257,
"end": 265,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 257,
"end": 261,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 262,
"end": 265,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 263,
"end": 265,
"ctxt": 0
},
"value": "p1",
"optional": false
}
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 266,
"end": 267,
"ctxt": 0
},
"value": "v",
"optional": false
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 278,
"end": 280,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 278,
"end": 279,
"ctxt": 0
},
"value": "v",
"optional": false
}
}
]
},
"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": 296,
"end": 300,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"declare": false,
"span": {
"start": 290,
"end": 486,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "PrivateMethod",
"span": {
"start": 307,
"end": 425,
"ctxt": 0
},
"key": {
"type": "PrivateName",
"span": {
"start": 307,
"end": 310,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 308,
"end": 310,
"ctxt": 0
},
"value": "p1",
"optional": false
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 311,
"end": 317,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 311,
"end": 317,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 312,
"end": 317,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 314,
"end": 317,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 307,
"end": 425,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 340,
"end": 425,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 350,
"end": 419,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 354,
"end": 375,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 354,
"end": 362,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 361,
"end": 362,
"ctxt": 0
},
"value": "v",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 367,
"end": 375,
"ctxt": 0
},
"value": "string",
"hasEscape": false,
"kind": {
"type": "normal",
"containsQuote": true
}
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 377,
"end": 419,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 391,
"end": 409,
"ctxt": 0
},
"argument": {
"type": "NewExpression",
"span": {
"start": 397,
"end": 408,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 401,
"end": 406,
"ctxt": 0
},
"value": "Error",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 318,
"end": 339,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 320,
"end": 339,
"ctxt": 0
},
"asserts": true,
"paramName": {
"type": "Identifier",
"span": {
"start": 328,
"end": 329,
"ctxt": 0
},
"value": "v",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 333,
"end": 339,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 333,
"end": 339,
"ctxt": 0
},
"kind": "string"
}
}
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 430,
"end": 484,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 430,
"end": 432,
"ctxt": 0
},
"value": "m1",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 433,
"end": 443,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 433,
"end": 443,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 434,
"end": 443,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 436,
"end": 443,
"ctxt": 0
},
"kind": "unknown"
}
}
}
}
],
"decorators": [],
"span": {
"start": 430,
"end": 484,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 445,
"end": 484,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 455,
"end": 467,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 455,
"end": 466,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 455,
"end": 463,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 455,
"end": 459,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 460,
"end": 463,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 461,
"end": 463,
"ctxt": 0
},
"value": "p1",
"optional": false
}
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 464,
"end": 465,
"ctxt": 0
},
"value": "v",
"optional": false
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 476,
"end": 478,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 476,
"end": 477,
"ctxt": 0
},
"value": "v",
"optional": false
}
}
]
},
"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": []
}
],
"interpreter": null
}