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

865 lines
25 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 81,
"end": 487,
"ctxt": 0
},
"body": [
{
"type": "ClassDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 87,
"end": 90,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"declare": false,
"span": {
"start": 81,
"end": 289,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "PrivateProperty",
"span": {
"start": 97,
"end": 228,
"ctxt": 0
},
"key": {
"type": "PrivateName",
"span": {
"start": 97,
"end": 100,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 98,
"end": 100,
"ctxt": 0
},
"value": "p1",
"optional": false
}
},
"value": {
"type": "ArrowFunctionExpression",
"span": {
"start": 136,
"end": 228,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 137,
"end": 138,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": null
}
],
"body": {
"type": "BlockStatement",
"span": {
"start": 143,
"end": 228,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 153,
"end": 222,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 157,
"end": 178,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 157,
"end": 165,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 164,
"end": 165,
"ctxt": 0
},
"value": "v",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 170,
"end": 178,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 180,
"end": 222,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 194,
"end": 212,
"ctxt": 0
},
"argument": {
"type": "NewExpression",
"span": {
"start": 200,
"end": 211,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 204,
"end": 209,
"ctxt": 0
},
"value": "Error",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
]
},
"async": false,
"generator": false,
"typeParameters": null,
"returnType": null
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 100,
"end": 133,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsFunctionType",
"span": {
"start": 102,
"end": 133,
"ctxt": 0
},
"params": [
{
"type": "Identifier",
"span": {
"start": 103,
"end": 109,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 104,
"end": 109,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 106,
"end": 109,
"ctxt": 0
},
"kind": "any"
}
}
}
],
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 111,
"end": 133,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 114,
"end": 133,
"ctxt": 0
},
"asserts": true,
"paramName": {
"type": "Identifier",
"span": {
"start": 122,
"end": 123,
"ctxt": 0
},
"value": "v",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 127,
"end": 133,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 127,
"end": 133,
"ctxt": 0
},
"kind": "string"
}
}
}
}
}
},
"isStatic": false,
"decorators": [],
"accessibility": null,
"isOptional": false,
"isOverride": false,
"readonly": false,
"definite": false
},
{
"type": "ClassMethod",
"span": {
"start": 233,
"end": 287,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 233,
"end": 235,
"ctxt": 0
},
"value": "m1",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 236,
"end": 246,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 236,
"end": 246,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 237,
"end": 246,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 239,
"end": 246,
"ctxt": 0
},
"kind": "unknown"
}
}
}
}
],
"decorators": [],
"span": {
"start": 233,
"end": 287,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 248,
"end": 287,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 258,
"end": 270,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 258,
"end": 269,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 258,
"end": 266,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 258,
"end": 262,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 263,
"end": 266,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 264,
"end": 266,
"ctxt": 0
},
"value": "p1",
"optional": false
}
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 267,
"end": 268,
"ctxt": 0
},
"value": "v",
"optional": false
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 279,
"end": 281,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 279,
"end": 280,
"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": 297,
"end": 301,
"ctxt": 0
},
"value": "Foo2",
"optional": false
},
"declare": false,
"span": {
"start": 291,
"end": 487,
"ctxt": 0
},
"decorators": [],
"body": [
{
"type": "PrivateMethod",
"span": {
"start": 308,
"end": 426,
"ctxt": 0
},
"key": {
"type": "PrivateName",
"span": {
"start": 308,
"end": 311,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 309,
"end": 311,
"ctxt": 0
},
"value": "p1",
"optional": false
}
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 312,
"end": 318,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 312,
"end": 318,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 313,
"end": 318,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 315,
"end": 318,
"ctxt": 0
},
"kind": "any"
}
}
}
}
],
"decorators": [],
"span": {
"start": 308,
"end": 426,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 341,
"end": 426,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 351,
"end": 420,
"ctxt": 0
},
"test": {
"type": "BinaryExpression",
"span": {
"start": 355,
"end": 376,
"ctxt": 0
},
"operator": "!==",
"left": {
"type": "UnaryExpression",
"span": {
"start": 355,
"end": 363,
"ctxt": 0
},
"operator": "typeof",
"argument": {
"type": "Identifier",
"span": {
"start": 362,
"end": 363,
"ctxt": 0
},
"value": "v",
"optional": false
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 368,
"end": 376,
"ctxt": 0
},
"value": "string",
"raw": "\"string\""
}
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 378,
"end": 420,
"ctxt": 0
},
"stmts": [
{
"type": "ThrowStatement",
"span": {
"start": 392,
"end": 410,
"ctxt": 0
},
"argument": {
"type": "NewExpression",
"span": {
"start": 398,
"end": 409,
"ctxt": 0
},
"callee": {
"type": "Identifier",
"span": {
"start": 402,
"end": 407,
"ctxt": 0
},
"value": "Error",
"optional": false
},
"arguments": [],
"typeArguments": null
}
}
]
},
"alternate": null
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 319,
"end": 340,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsTypePredicate",
"span": {
"start": 321,
"end": 340,
"ctxt": 0
},
"asserts": true,
"paramName": {
"type": "Identifier",
"span": {
"start": 329,
"end": 330,
"ctxt": 0
},
"value": "v",
"optional": false
},
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 334,
"end": 340,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 334,
"end": 340,
"ctxt": 0
},
"kind": "string"
}
}
}
}
},
"kind": "method",
"isStatic": false,
"accessibility": null,
"isAbstract": false,
"isOptional": false,
"isOverride": false
},
{
"type": "ClassMethod",
"span": {
"start": 431,
"end": 485,
"ctxt": 0
},
"key": {
"type": "Identifier",
"span": {
"start": 431,
"end": 433,
"ctxt": 0
},
"value": "m1",
"optional": false
},
"function": {
"params": [
{
"type": "Parameter",
"span": {
"start": 434,
"end": 444,
"ctxt": 0
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 434,
"end": 444,
"ctxt": 0
},
"value": "v",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 435,
"end": 444,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 437,
"end": 444,
"ctxt": 0
},
"kind": "unknown"
}
}
}
}
],
"decorators": [],
"span": {
"start": 431,
"end": 485,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 446,
"end": 485,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 456,
"end": 468,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 456,
"end": 467,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 456,
"end": 464,
"ctxt": 0
},
"object": {
"type": "ThisExpression",
"span": {
"start": 456,
"end": 460,
"ctxt": 0
}
},
"property": {
"type": "PrivateName",
"span": {
"start": 461,
"end": 464,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 462,
"end": 464,
"ctxt": 0
},
"value": "p1",
"optional": false
}
}
},
"arguments": [
{
"spread": null,
"expression": {
"type": "Identifier",
"span": {
"start": 465,
"end": 466,
"ctxt": 0
},
"value": "v",
"optional": false
}
}
],
"typeArguments": null
}
},
{
"type": "ExpressionStatement",
"span": {
"start": 477,
"end": 479,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 477,
"end": 478,
"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
}