Add support for class private methods (#703)

* Add support for class private methods

This commit adds parser support for the TC39 Stage 2 Private Methods
proposal.

This commit also changes "key" in ClassPrivateProperty from an
Identifier to a PrivateName, as well as disallowing #constructor as a
valid private field name.

* Add tests for string literal get/set/async

These should be treated as regular methods and not special get/set/async
behaviour.

* Add tests for class private methods

This also removes a test from the Test262 whitelist that failed before
the changes for private methods support and now passes.

* Modify class private prop tests for PrivateName

* Add class private prop tests for #constructor

* Fix existing ASI test case failure
This commit is contained in:
Karl Cheng
2017-09-07 08:09:12 +10:00
committed by Justin Ridgewell
parent b65b5a2f1c
commit 65bea96544
54 changed files with 3430 additions and 425 deletions

View File

@@ -0,0 +1,3 @@
class A {
["async"] a() {}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (2:12)"
}

View File

@@ -0,0 +1,3 @@
class A {
["get"] a() {}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (2:10)"
}

View File

@@ -0,0 +1,3 @@
class A {
"async" a() {}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (2:10)"
}

View File

@@ -0,0 +1,3 @@
class A {
"get" a() {}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token (2:8)"
}

View File

@@ -12,6 +12,16 @@ class A {
() {}
'get'
() {}
'set'
() {}
'async'
() {}
static
get
() {}
@@ -42,4 +52,4 @@ class A {
get
static
() {}
}
}

View File

@@ -1,28 +1,28 @@
{
"type": "File",
"start": 0,
"end": 257,
"end": 311,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 45,
"line": 55,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 257,
"end": 311,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 45,
"line": 55,
"column": 1
}
},
@@ -31,14 +31,14 @@
{
"type": "ClassDeclaration",
"start": 0,
"end": 257,
"end": 311,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 45,
"line": 55,
"column": 1
}
},
@@ -63,14 +63,14 @@
"body": {
"type": "ClassBody",
"start": 8,
"end": 257,
"end": 311,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 45,
"line": 55,
"column": 1
}
},
@@ -90,7 +90,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 12,
@@ -108,6 +107,7 @@
},
"name": "get"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -147,7 +147,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 27,
@@ -165,6 +164,7 @@
},
"name": "set"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -203,7 +203,6 @@
"column": 7
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
@@ -223,6 +222,7 @@
},
"name": "static"
},
"static": false,
"id": null,
"generator": false,
"expression": false,
@@ -261,7 +261,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 60,
@@ -279,6 +278,7 @@
},
"name": "async"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -306,36 +306,216 @@
{
"type": "ClassMethod",
"start": 78,
"end": 98,
"end": 91,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 17,
"line": 16,
"column": 7
}
},
"static": false,
"key": {
"type": "StringLiteral",
"start": 78,
"end": 83,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 15,
"column": 7
}
},
"extra": {
"rawValue": "get",
"raw": "'get'"
},
"value": "get"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 89,
"end": 91,
"loc": {
"start": {
"line": 16,
"column": 5
},
"end": {
"line": 16,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 95,
"end": 108,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 19,
"column": 7
}
},
"static": false,
"key": {
"type": "StringLiteral",
"start": 95,
"end": 100,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 18,
"column": 7
}
},
"extra": {
"rawValue": "set",
"raw": "'set'"
},
"value": "set"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 106,
"end": 108,
"loc": {
"start": {
"line": 19,
"column": 5
},
"end": {
"line": 19,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 112,
"end": 127,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 22,
"column": 7
}
},
"static": false,
"key": {
"type": "StringLiteral",
"start": 112,
"end": 119,
"loc": {
"start": {
"line": 21,
"column": 2
},
"end": {
"line": 21,
"column": 9
}
},
"extra": {
"rawValue": "async",
"raw": "'async'"
},
"value": "async"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 125,
"end": 127,
"loc": {
"start": {
"line": 22,
"column": 5
},
"end": {
"line": 22,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 132,
"end": 152,
"loc": {
"start": {
"line": 25,
"column": 2
},
"end": {
"line": 27,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 87,
"end": 90,
"start": 141,
"end": 144,
"loc": {
"start": {
"line": 16,
"line": 26,
"column": 2
},
"end": {
"line": 16,
"line": 26,
"column": 5
},
"identifierName": "get"
},
"name": "get"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -344,15 +524,15 @@
"params": [],
"body": {
"type": "BlockStatement",
"start": 96,
"end": 98,
"start": 150,
"end": 152,
"loc": {
"start": {
"line": 17,
"line": 27,
"column": 5
},
"end": {
"line": 17,
"line": 27,
"column": 7
}
},
@@ -362,37 +542,37 @@
},
{
"type": "ClassMethod",
"start": 102,
"end": 122,
"start": 156,
"end": 176,
"loc": {
"start": {
"line": 19,
"line": 29,
"column": 2
},
"end": {
"line": 21,
"line": 31,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 111,
"end": 114,
"start": 165,
"end": 168,
"loc": {
"start": {
"line": 20,
"line": 30,
"column": 2
},
"end": {
"line": 20,
"line": 30,
"column": 5
},
"identifierName": "set"
},
"name": "set"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -401,15 +581,15 @@
"params": [],
"body": {
"type": "BlockStatement",
"start": 120,
"end": 122,
"start": 174,
"end": 176,
"loc": {
"start": {
"line": 21,
"line": 31,
"column": 5
},
"end": {
"line": 21,
"line": 31,
"column": 7
}
},
@@ -419,37 +599,37 @@
},
{
"type": "ClassMethod",
"start": 126,
"end": 149,
"start": 180,
"end": 203,
"loc": {
"start": {
"line": 23,
"line": 33,
"column": 2
},
"end": {
"line": 25,
"line": 35,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 135,
"end": 141,
"start": 189,
"end": 195,
"loc": {
"start": {
"line": 24,
"line": 34,
"column": 2
},
"end": {
"line": 24,
"line": 34,
"column": 8
},
"identifierName": "static"
},
"name": "static"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -458,15 +638,15 @@
"params": [],
"body": {
"type": "BlockStatement",
"start": 147,
"end": 149,
"start": 201,
"end": 203,
"loc": {
"start": {
"line": 25,
"line": 35,
"column": 5
},
"end": {
"line": 25,
"line": 35,
"column": 7
}
},
@@ -476,169 +656,55 @@
},
{
"type": "ClassMethod",
"start": 153,
"end": 175,
"start": 207,
"end": 229,
"loc": {
"start": {
"line": 27,
"line": 37,
"column": 2
},
"end": {
"line": 29,
"line": 39,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 162,
"end": 167,
"loc": {
"start": {
"line": 28,
"column": 2
},
"end": {
"line": 28,
"column": 7
},
"identifierName": "async"
},
"name": "async"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 173,
"end": 175,
"loc": {
"start": {
"line": 29,
"column": 5
},
"end": {
"line": 29,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 179,
"end": 197,
"loc": {
"start": {
"line": 31,
"column": 2
},
"end": {
"line": 33,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 188,
"end": 189,
"loc": {
"start": {
"line": 32,
"column": 2
},
"end": {
"line": 32,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 195,
"end": 197,
"loc": {
"start": {
"line": 33,
"column": 5
},
"end": {
"line": 33,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 202,
"end": 221,
"loc": {
"start": {
"line": 36,
"column": 2
},
"end": {
"line": 38,
"column": 7
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 208,
"end": 213,
"loc": {
"start": {
"line": 37,
"column": 2
},
"end": {
"line": 37,
"column": 7
},
"identifierName": "async"
},
"name": "async"
},
"kind": "get",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 219,
"start": 216,
"end": 221,
"loc": {
"start": {
"line": 38,
"column": 5
"column": 2
},
"end": {
"line": 38,
"column": 7
},
"identifierName": "async"
},
"name": "async"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 227,
"end": 229,
"loc": {
"start": {
"line": 39,
"column": 5
},
"end": {
"line": 39,
"column": 7
}
},
"body": [],
@@ -647,37 +713,94 @@
},
{
"type": "ClassMethod",
"start": 226,
"end": 255,
"start": 233,
"end": 251,
"loc": {
"start": {
"line": 41,
"column": 2
},
"end": {
"line": 44,
"line": 43,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 241,
"end": 247,
"start": 242,
"end": 243,
"loc": {
"start": {
"line": 43,
"line": 42,
"column": 2
},
"end": {
"line": 43,
"column": 8
"line": 42,
"column": 3
},
"identifierName": "static"
"identifierName": "a"
},
"name": "static"
"name": "a"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 249,
"end": 251,
"loc": {
"start": {
"line": 43,
"column": 5
},
"end": {
"line": 43,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 256,
"end": 275,
"loc": {
"start": {
"line": 46,
"column": 2
},
"end": {
"line": 48,
"column": 7
}
},
"static": false,
"key": {
"type": "Identifier",
"start": 262,
"end": 267,
"loc": {
"start": {
"line": 47,
"column": 2
},
"end": {
"line": 47,
"column": 7
},
"identifierName": "async"
},
"name": "async"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
@@ -686,15 +809,72 @@
"params": [],
"body": {
"type": "BlockStatement",
"start": 253,
"end": 255,
"start": 273,
"end": 275,
"loc": {
"start": {
"line": 44,
"line": 48,
"column": 5
},
"end": {
"line": 44,
"line": 48,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 280,
"end": 309,
"loc": {
"start": {
"line": 51,
"column": 2
},
"end": {
"line": 54,
"column": 7
}
},
"static": true,
"key": {
"type": "Identifier",
"start": 295,
"end": 301,
"loc": {
"start": {
"line": 53,
"column": 2
},
"end": {
"line": 53,
"column": 8
},
"identifierName": "static"
},
"name": "static"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 307,
"end": 309,
"loc": {
"start": {
"line": 54,
"column": 5
},
"end": {
"line": 54,
"column": 7
}
},

View File

@@ -0,0 +1,4 @@
class Foo {
p = x
*#m () {}
}

View File

@@ -0,0 +1,4 @@
{
"throws": "Unexpected token (3:3)",
"plugins": ["classProperties", "classPrivateMethods"]
}

View File

@@ -0,0 +1,13 @@
class Foo {
async* #readLines(path) {
let file = await fileOpen(path);
try {
while (!file.EOF) {
yield await file.readLine();
}
} finally {
await file.close();
}
}
}

View File

@@ -0,0 +1,655 @@
{
"type": "File",
"start": 0,
"end": 212,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 13,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 212,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 13,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 212,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 13,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 9
},
"identifierName": "Foo"
},
"name": "Foo"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 10,
"end": 212,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 13,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 14,
"end": 210,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 12,
"column": 3
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 22,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 22,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 19
},
"identifierName": "readLines"
},
"name": "readLines"
}
},
"computed": false,
"kind": "method",
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [
{
"type": "Identifier",
"start": 32,
"end": 36,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 24
},
"identifierName": "path"
},
"name": "path"
}
],
"body": {
"type": "BlockStatement",
"start": 38,
"end": 210,
"loc": {
"start": {
"line": 2,
"column": 26
},
"end": {
"line": 12,
"column": 3
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 44,
"end": 76,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 36
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 48,
"end": 75,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 35
}
},
"id": {
"type": "Identifier",
"start": 48,
"end": 52,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 12
},
"identifierName": "file"
},
"name": "file"
},
"init": {
"type": "AwaitExpression",
"start": 55,
"end": 75,
"loc": {
"start": {
"line": 3,
"column": 15
},
"end": {
"line": 3,
"column": 35
}
},
"argument": {
"type": "CallExpression",
"start": 61,
"end": 75,
"loc": {
"start": {
"line": 3,
"column": 21
},
"end": {
"line": 3,
"column": 35
}
},
"callee": {
"type": "Identifier",
"start": 61,
"end": 69,
"loc": {
"start": {
"line": 3,
"column": 21
},
"end": {
"line": 3,
"column": 29
},
"identifierName": "fileOpen"
},
"name": "fileOpen"
},
"arguments": [
{
"type": "Identifier",
"start": 70,
"end": 74,
"loc": {
"start": {
"line": 3,
"column": 30
},
"end": {
"line": 3,
"column": 34
},
"identifierName": "path"
},
"name": "path"
}
]
}
}
}
],
"kind": "let"
},
{
"type": "TryStatement",
"start": 82,
"end": 206,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 11,
"column": 5
}
},
"block": {
"type": "BlockStatement",
"start": 86,
"end": 164,
"loc": {
"start": {
"line": 5,
"column": 8
},
"end": {
"line": 9,
"column": 5
}
},
"body": [
{
"type": "WhileStatement",
"start": 94,
"end": 158,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 8,
"column": 7
}
},
"test": {
"type": "UnaryExpression",
"start": 101,
"end": 110,
"loc": {
"start": {
"line": 6,
"column": 13
},
"end": {
"line": 6,
"column": 22
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "MemberExpression",
"start": 102,
"end": 110,
"loc": {
"start": {
"line": 6,
"column": 14
},
"end": {
"line": 6,
"column": 22
}
},
"object": {
"type": "Identifier",
"start": 102,
"end": 106,
"loc": {
"start": {
"line": 6,
"column": 14
},
"end": {
"line": 6,
"column": 18
},
"identifierName": "file"
},
"name": "file"
},
"property": {
"type": "Identifier",
"start": 107,
"end": 110,
"loc": {
"start": {
"line": 6,
"column": 19
},
"end": {
"line": 6,
"column": 22
},
"identifierName": "EOF"
},
"name": "EOF"
},
"computed": false
},
"extra": {
"parenthesizedArgument": false
}
},
"body": {
"type": "BlockStatement",
"start": 112,
"end": 158,
"loc": {
"start": {
"line": 6,
"column": 24
},
"end": {
"line": 8,
"column": 7
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 122,
"end": 150,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 36
}
},
"expression": {
"type": "YieldExpression",
"start": 122,
"end": 149,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 35
}
},
"delegate": false,
"argument": {
"type": "AwaitExpression",
"start": 128,
"end": 149,
"loc": {
"start": {
"line": 7,
"column": 14
},
"end": {
"line": 7,
"column": 35
}
},
"argument": {
"type": "CallExpression",
"start": 134,
"end": 149,
"loc": {
"start": {
"line": 7,
"column": 20
},
"end": {
"line": 7,
"column": 35
}
},
"callee": {
"type": "MemberExpression",
"start": 134,
"end": 147,
"loc": {
"start": {
"line": 7,
"column": 20
},
"end": {
"line": 7,
"column": 33
}
},
"object": {
"type": "Identifier",
"start": 134,
"end": 138,
"loc": {
"start": {
"line": 7,
"column": 20
},
"end": {
"line": 7,
"column": 24
},
"identifierName": "file"
},
"name": "file"
},
"property": {
"type": "Identifier",
"start": 139,
"end": 147,
"loc": {
"start": {
"line": 7,
"column": 25
},
"end": {
"line": 7,
"column": 33
},
"identifierName": "readLine"
},
"name": "readLine"
},
"computed": false
},
"arguments": []
}
}
}
}
],
"directives": []
}
}
],
"directives": []
},
"handler": null,
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 173,
"end": 206,
"loc": {
"start": {
"line": 9,
"column": 14
},
"end": {
"line": 11,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 181,
"end": 200,
"loc": {
"start": {
"line": 10,
"column": 6
},
"end": {
"line": 10,
"column": 25
}
},
"expression": {
"type": "AwaitExpression",
"start": 181,
"end": 199,
"loc": {
"start": {
"line": 10,
"column": 6
},
"end": {
"line": 10,
"column": 24
}
},
"argument": {
"type": "CallExpression",
"start": 187,
"end": 199,
"loc": {
"start": {
"line": 10,
"column": 12
},
"end": {
"line": 10,
"column": 24
}
},
"callee": {
"type": "MemberExpression",
"start": 187,
"end": 197,
"loc": {
"start": {
"line": 10,
"column": 12
},
"end": {
"line": 10,
"column": 22
}
},
"object": {
"type": "Identifier",
"start": 187,
"end": 191,
"loc": {
"start": {
"line": 10,
"column": 12
},
"end": {
"line": 10,
"column": 16
},
"identifierName": "file"
},
"name": "file"
},
"property": {
"type": "Identifier",
"start": 192,
"end": 197,
"loc": {
"start": {
"line": 10,
"column": 17
},
"end": {
"line": 10,
"column": 22
},
"identifierName": "close"
},
"name": "close"
},
"computed": false
},
"arguments": []
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classProperties", "classPrivateMethods", "asyncGenerators"]
}

View File

@@ -0,0 +1,5 @@
class Hotel {
async #evil() {
await notReally();
}
}

View File

@@ -0,0 +1,220 @@
{
"type": "File",
"start": 0,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "Hotel"
},
"name": "Hotel"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 12,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 5,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 16,
"end": 58,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 4,
"column": 3
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 23,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 13
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 13
},
"identifierName": "evil"
},
"name": "evil"
}
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start": 30,
"end": 58,
"loc": {
"start": {
"line": 2,
"column": 16
},
"end": {
"line": 4,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 36,
"end": 54,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 22
}
},
"expression": {
"type": "AwaitExpression",
"start": 36,
"end": 53,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 21
}
},
"argument": {
"type": "CallExpression",
"start": 42,
"end": 53,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 21
}
},
"callee": {
"type": "Identifier",
"start": 42,
"end": 51,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 19
},
"identifierName": "notReally"
},
"name": "notReally"
},
"arguments": []
}
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classProperties", "classPrivateMethods"]
}

View File

@@ -0,0 +1,16 @@
class Foo {
a = 1;
*#a() {
yield bar();
}
#b = 2;
get b() { return 9999; }
set #c(x) { return x; }
#d() {
return Math.random();
}
}

View File

@@ -0,0 +1,711 @@
{
"type": "File",
"start": 0,
"end": 159,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 16,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 159,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 16,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 159,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 16,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 9
},
"identifierName": "Foo"
},
"name": "Foo"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 10,
"end": 159,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 16,
"column": 1
}
},
"body": [
{
"type": "ClassProperty",
"start": 14,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 8
}
},
"static": false,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"computed": false,
"value": {
"type": "NumericLiteral",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
{
"type": "ClassPrivateMethod",
"start": 24,
"end": 52,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 6,
"column": 3
}
},
"static": false,
"kind": "method",
"key": {
"type": "PrivateName",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 5
},
"identifierName": "a"
},
"name": "a"
}
},
"id": null,
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 30,
"end": 52,
"loc": {
"start": {
"line": 4,
"column": 8
},
"end": {
"line": 6,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 36,
"end": 48,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 5,
"column": 16
}
},
"expression": {
"type": "YieldExpression",
"start": 36,
"end": 47,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 5,
"column": 15
}
},
"delegate": false,
"argument": {
"type": "CallExpression",
"start": 42,
"end": 47,
"loc": {
"start": {
"line": 5,
"column": 10
},
"end": {
"line": 5,
"column": 15
}
},
"callee": {
"type": "Identifier",
"start": 42,
"end": 45,
"loc": {
"start": {
"line": 5,
"column": 10
},
"end": {
"line": 5,
"column": 13
},
"identifierName": "bar"
},
"name": "bar"
},
"arguments": []
}
}
}
],
"directives": []
}
},
{
"type": "ClassPrivateProperty",
"start": 56,
"end": 63,
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 8,
"column": 9
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 57,
"end": 58,
"loc": {
"start": {
"line": 8,
"column": 3
},
"end": {
"line": 8,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 57,
"end": 58,
"loc": {
"start": {
"line": 8,
"column": 3
},
"end": {
"line": 8,
"column": 4
},
"identifierName": "b"
},
"name": "b"
}
},
"value": {
"type": "NumericLiteral",
"start": 61,
"end": 62,
"loc": {
"start": {
"line": 8,
"column": 7
},
"end": {
"line": 8,
"column": 8
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
},
{
"type": "ClassMethod",
"start": 67,
"end": 91,
"loc": {
"start": {
"line": 10,
"column": 2
},
"end": {
"line": 10,
"column": 26
}
},
"static": false,
"key": {
"type": "Identifier",
"start": 71,
"end": 72,
"loc": {
"start": {
"line": 10,
"column": 6
},
"end": {
"line": 10,
"column": 7
},
"identifierName": "b"
},
"name": "b"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 75,
"end": 91,
"loc": {
"start": {
"line": 10,
"column": 10
},
"end": {
"line": 10,
"column": 26
}
},
"body": [
{
"type": "ReturnStatement",
"start": 77,
"end": 89,
"loc": {
"start": {
"line": 10,
"column": 12
},
"end": {
"line": 10,
"column": 24
}
},
"argument": {
"type": "NumericLiteral",
"start": 84,
"end": 88,
"loc": {
"start": {
"line": 10,
"column": 19
},
"end": {
"line": 10,
"column": 23
}
},
"extra": {
"rawValue": 9999,
"raw": "9999"
},
"value": 9999
}
}
],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 94,
"end": 117,
"loc": {
"start": {
"line": 11,
"column": 2
},
"end": {
"line": 11,
"column": 25
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 99,
"end": 100,
"loc": {
"start": {
"line": 11,
"column": 7
},
"end": {
"line": 11,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 99,
"end": 100,
"loc": {
"start": {
"line": 11,
"column": 7
},
"end": {
"line": 11,
"column": 8
},
"identifierName": "c"
},
"name": "c"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 101,
"end": 102,
"loc": {
"start": {
"line": 11,
"column": 9
},
"end": {
"line": 11,
"column": 10
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BlockStatement",
"start": 104,
"end": 117,
"loc": {
"start": {
"line": 11,
"column": 12
},
"end": {
"line": 11,
"column": 25
}
},
"body": [
{
"type": "ReturnStatement",
"start": 106,
"end": 115,
"loc": {
"start": {
"line": 11,
"column": 14
},
"end": {
"line": 11,
"column": 23
}
},
"argument": {
"type": "Identifier",
"start": 113,
"end": 114,
"loc": {
"start": {
"line": 11,
"column": 21
},
"end": {
"line": 11,
"column": 22
},
"identifierName": "x"
},
"name": "x"
}
}
],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 121,
"end": 157,
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 15,
"column": 3
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 122,
"end": 123,
"loc": {
"start": {
"line": 13,
"column": 3
},
"end": {
"line": 13,
"column": 4
}
},
"id": {
"type": "Identifier",
"start": 122,
"end": 123,
"loc": {
"start": {
"line": 13,
"column": 3
},
"end": {
"line": 13,
"column": 4
},
"identifierName": "d"
},
"name": "d"
}
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 126,
"end": 157,
"loc": {
"start": {
"line": 13,
"column": 7
},
"end": {
"line": 15,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 132,
"end": 153,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 25
}
},
"argument": {
"type": "CallExpression",
"start": 139,
"end": 152,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 24
}
},
"callee": {
"type": "MemberExpression",
"start": 139,
"end": 150,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 22
}
},
"object": {
"type": "Identifier",
"start": 139,
"end": 143,
"loc": {
"start": {
"line": 14,
"column": 11
},
"end": {
"line": 14,
"column": 15
},
"identifierName": "Math"
},
"name": "Math"
},
"property": {
"type": "Identifier",
"start": 144,
"end": 150,
"loc": {
"start": {
"line": 14,
"column": 16
},
"end": {
"line": 14,
"column": 22
},
"identifierName": "random"
},
"name": "random"
},
"computed": false
},
"arguments": []
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classProperties", "classPrivateProperties", "classPrivateMethods"]
}

View File

@@ -0,0 +1,3 @@
class Foo {
#constructor() {};
}

View File

@@ -0,0 +1,7 @@
{
"throws": "Classes may not have a private field named '#constructor' (2:3)",
"plugins": [
"classProperties",
"classPrivateMethods"
]
}

View File

@@ -0,0 +1,4 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: 'classPrivateMethods' (3:3)",
"plugins": ["classProperties", "classPrivateProperties"]
}

View File

@@ -0,0 +1,5 @@
class Hotel {
*#evil() {
yield notReally();
}
}

View File

@@ -0,0 +1,220 @@
{
"type": "File",
"start": 0,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "Hotel"
},
"name": "Hotel"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 12,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 5,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 16,
"end": 53,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 4,
"column": 3
}
},
"static": false,
"kind": "method",
"key": {
"type": "PrivateName",
"start": 18,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 8
}
},
"id": {
"type": "Identifier",
"start": 18,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "evil"
},
"name": "evil"
}
},
"id": null,
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 25,
"end": 53,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 4,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 31,
"end": 49,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 22
}
},
"expression": {
"type": "YieldExpression",
"start": 31,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 21
}
},
"delegate": false,
"argument": {
"type": "CallExpression",
"start": 37,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 21
}
},
"callee": {
"type": "Identifier",
"start": 37,
"end": 46,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 19
},
"identifierName": "notReally"
},
"name": "notReally"
},
"arguments": []
}
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classProperties", "classPrivateMethods"]
}

View File

@@ -0,0 +1,8 @@
class Hotel {
get #evil() {
return ohNo();
}
set #evil(x) {
return makeEvil(x);
}
}

View File

@@ -0,0 +1,362 @@
{
"type": "File",
"start": 0,
"end": 99,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 99,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 99,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "Hotel"
},
"name": "Hotel"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 12,
"end": 99,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 8,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 16,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 4,
"column": 3
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 21,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 21,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "evil"
},
"name": "evil"
}
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 28,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 14
},
"end": {
"line": 4,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 34,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 18
}
},
"argument": {
"type": "CallExpression",
"start": 41,
"end": 47,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 17
}
},
"callee": {
"type": "Identifier",
"start": 41,
"end": 45,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "ohNo"
},
"name": "ohNo"
},
"arguments": []
}
}
],
"directives": []
}
},
{
"type": "ClassPrivateMethod",
"start": 55,
"end": 97,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 7,
"column": 3
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 60,
"end": 64,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 11
}
},
"id": {
"type": "Identifier",
"start": 60,
"end": 64,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 11
},
"identifierName": "evil"
},
"name": "evil"
}
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 65,
"end": 66,
"loc": {
"start": {
"line": 5,
"column": 12
},
"end": {
"line": 5,
"column": 13
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BlockStatement",
"start": 68,
"end": 97,
"loc": {
"start": {
"line": 5,
"column": 15
},
"end": {
"line": 7,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 74,
"end": 93,
"loc": {
"start": {
"line": 6,
"column": 4
},
"end": {
"line": 6,
"column": 23
}
},
"argument": {
"type": "CallExpression",
"start": 81,
"end": 92,
"loc": {
"start": {
"line": 6,
"column": 11
},
"end": {
"line": 6,
"column": 22
}
},
"callee": {
"type": "Identifier",
"start": 81,
"end": 89,
"loc": {
"start": {
"line": 6,
"column": 11
},
"end": {
"line": 6,
"column": 19
},
"identifierName": "makeEvil"
},
"name": "makeEvil"
},
"arguments": [
{
"type": "Identifier",
"start": 90,
"end": 91,
"loc": {
"start": {
"line": 6,
"column": 20
},
"end": {
"line": 6,
"column": 21
},
"identifierName": "x"
},
"name": "x"
}
]
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classProperties", "classPrivateMethods"]
}

View File

@@ -0,0 +1,5 @@
class Hotel {
#getBanned() {
return violentPeople();
}
}

View File

@@ -0,0 +1,204 @@
{
"type": "File",
"start": 0,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "Hotel"
},
"name": "Hotel"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 12,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 5,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateMethod",
"start": 16,
"end": 62,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 4,
"column": 3
}
},
"static": false,
"key": {
"type": "PrivateName",
"start": 17,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 17,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "getBanned"
},
"name": "getBanned"
}
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 29,
"end": 62,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 4,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 35,
"end": 58,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 27
}
},
"argument": {
"type": "CallExpression",
"start": 42,
"end": 57,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 26
}
},
"callee": {
"type": "Identifier",
"start": 42,
"end": 55,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 24
},
"identifierName": "violentPeople"
},
"name": "violentPeople"
},
"arguments": []
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"plugins": ["classProperties", "classPrivateMethods"]
}

View File

@@ -1,4 +1,4 @@
{
"throws": "Unexpected token, expected ; (2:5)",
"throws": "Unexpected token (2:5)",
"plugins": ["classProperties", "classPrivateProperties"]
}

View File

@@ -89,8 +89,9 @@
"column": 4
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 15,
"end": 16,
"loc": {
@@ -101,12 +102,26 @@
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
}
},
"name": "x"
"id": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"static": false,
"value": null
},
{
@@ -123,8 +138,9 @@
"column": 4
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 20,
"end": 21,
"loc": {
@@ -135,12 +151,26 @@
"end": {
"line": 3,
"column": 4
},
"identifierName": "y"
}
},
"name": "y"
"id": {
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "y"
},
"name": "y"
}
},
"static": false,
"value": null
}
]
@@ -149,4 +179,4 @@
],
"directives": []
}
}
}

View File

@@ -1,4 +0,0 @@
{
"throws": "Unexpected token, expected ; (3:5)",
"plugins": ["classProperties", "classPrivateProperties"]
}

View File

@@ -0,0 +1,3 @@
class Foo {
#constructor;
}

View File

@@ -0,0 +1,7 @@
{
"throws": "Classes may not have a private field named '#constructor' (2:3)",
"plugins": [
"classProperties",
"classPrivateProperties"
]
}

View File

@@ -89,8 +89,9 @@
"column": 13
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 11,
"end": 12,
"loc": {
@@ -101,12 +102,26 @@
"end": {
"line": 1,
"column": 12
},
"identifierName": "x"
}
},
"name": "x"
"id": {
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "x"
},
"name": "x"
}
},
"static": false,
"value": null
},
{
@@ -123,8 +138,9 @@
"column": 17
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 15,
"end": 16,
"loc": {
@@ -135,12 +151,26 @@
"end": {
"line": 1,
"column": 16
},
"identifierName": "y"
}
},
"name": "y"
"id": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
},
"identifierName": "y"
},
"name": "y"
}
},
"static": false,
"value": null
}
]
@@ -207,8 +237,9 @@
"column": 17
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 32,
"end": 33,
"loc": {
@@ -219,12 +250,26 @@
"end": {
"line": 3,
"column": 12
},
"identifierName": "x"
}
},
"name": "x"
"id": {
"type": "Identifier",
"start": 32,
"end": 33,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 12
},
"identifierName": "x"
},
"name": "x"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 36,
@@ -260,8 +305,9 @@
"column": 25
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 40,
"end": 41,
"loc": {
@@ -272,12 +318,26 @@
"end": {
"line": 3,
"column": 20
},
"identifierName": "y"
}
},
"name": "y"
"id": {
"type": "Identifier",
"start": 40,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 19
},
"end": {
"line": 3,
"column": 20
},
"identifierName": "y"
},
"name": "y"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 44,
@@ -305,4 +365,4 @@
],
"directives": []
}
}
}

View File

@@ -89,8 +89,9 @@
"column": 9
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 17,
"end": 18,
"loc": {
@@ -101,12 +102,26 @@
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
}
},
"name": "x"
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 21,
@@ -142,8 +157,9 @@
"column": 9
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 27,
"end": 28,
"loc": {
@@ -154,12 +170,26 @@
"end": {
"line": 3,
"column": 4
},
"identifierName": "y"
}
},
"name": "y"
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "y"
},
"name": "y"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 31,
@@ -196,7 +226,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 37,
@@ -214,6 +243,7 @@
},
"name": "constructor"
},
"computed": false,
"kind": "constructor",
"id": null,
"generator": false,
@@ -724,8 +754,9 @@
"column": 13
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 132,
"end": 133,
"loc": {
@@ -736,12 +767,26 @@
"end": {
"line": 10,
"column": 8
},
"identifierName": "x"
}
},
"name": "x"
"id": {
"type": "Identifier",
"start": 132,
"end": 133,
"loc": {
"start": {
"line": 10,
"column": 7
},
"end": {
"line": 10,
"column": 8
},
"identifierName": "x"
},
"name": "x"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 136,
@@ -777,8 +822,9 @@
"column": 13
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 146,
"end": 147,
"loc": {
@@ -789,12 +835,26 @@
"end": {
"line": 11,
"column": 8
},
"identifierName": "y"
}
},
"name": "y"
"id": {
"type": "Identifier",
"start": 146,
"end": 147,
"loc": {
"start": {
"line": 11,
"column": 7
},
"end": {
"line": 11,
"column": 8
},
"identifierName": "y"
},
"name": "y"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 150,
@@ -831,7 +891,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 160,
@@ -849,6 +908,7 @@
},
"name": "constructor"
},
"computed": false,
"kind": "constructor",
"id": null,
"generator": false,
@@ -1256,7 +1316,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 251,
@@ -1274,6 +1333,7 @@
},
"name": "x"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
@@ -1392,7 +1452,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 284,
@@ -1410,6 +1469,7 @@
},
"name": "x"
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
@@ -1599,7 +1659,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 325,
@@ -1617,6 +1676,7 @@
},
"name": "y"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
@@ -1735,7 +1795,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 358,
@@ -1753,6 +1812,7 @@
},
"name": "y"
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
@@ -1942,7 +2002,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 395,
@@ -1960,6 +2019,7 @@
},
"name": "equals"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -2337,7 +2397,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 460,
@@ -2355,6 +2414,7 @@
},
"name": "toString"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -2624,7 +2684,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 535,
@@ -2642,6 +2701,7 @@
},
"name": "x"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
@@ -2760,7 +2820,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 564,
@@ -2778,6 +2837,7 @@
},
"name": "x"
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
@@ -2967,7 +3027,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 601,
@@ -2985,6 +3044,7 @@
},
"name": "y"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
@@ -3103,7 +3163,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 630,
@@ -3121,6 +3180,7 @@
},
"name": "y"
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
@@ -3310,7 +3370,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 663,
@@ -3328,6 +3387,7 @@
},
"name": "equals"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -3705,7 +3765,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 724,
@@ -3723,6 +3782,7 @@
},
"name": "toString"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,

View File

@@ -89,8 +89,9 @@
"column": 9
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 17,
"end": 18,
"loc": {
@@ -101,12 +102,26 @@
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
}
},
"name": "x"
"id": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 4
},
"identifierName": "x"
},
"name": "x"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 21,
@@ -142,8 +157,9 @@
"column": 9
}
},
"static": false,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 27,
"end": 28,
"loc": {
@@ -154,12 +170,26 @@
"end": {
"line": 3,
"column": 4
},
"identifierName": "y"
}
},
"name": "y"
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 4
},
"identifierName": "y"
},
"name": "y"
}
},
"static": false,
"value": {
"type": "NumericLiteral",
"start": 31,
@@ -196,7 +226,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 37,
@@ -214,6 +243,7 @@
},
"name": "constructor"
},
"computed": false,
"kind": "constructor",
"id": null,
"generator": false,
@@ -621,7 +651,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 112,
@@ -639,6 +668,7 @@
},
"name": "x"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
@@ -757,7 +787,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 141,
@@ -775,6 +804,7 @@
},
"name": "x"
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
@@ -964,7 +994,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 178,
@@ -982,6 +1011,7 @@
},
"name": "y"
},
"computed": false,
"kind": "get",
"id": null,
"generator": false,
@@ -1100,7 +1130,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 207,
@@ -1118,6 +1147,7 @@
},
"name": "y"
},
"computed": false,
"kind": "set",
"id": null,
"generator": false,
@@ -1307,7 +1337,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 240,
@@ -1325,6 +1354,7 @@
},
"name": "equals"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
@@ -1702,7 +1732,6 @@
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 301,
@@ -1720,6 +1749,7 @@
},
"name": "toString"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,

View File

@@ -89,8 +89,9 @@
"column": 12
}
},
"static": true,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 20,
"end": 21,
"loc": {
@@ -101,12 +102,26 @@
"end": {
"line": 2,
"column": 11
},
"identifierName": "x"
}
},
"name": "x"
"id": {
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "x"
},
"name": "x"
}
},
"static": true,
"value": null
},
{
@@ -123,8 +138,9 @@
"column": 16
}
},
"static": true,
"key": {
"type": "Identifier",
"type": "PrivateName",
"start": 33,
"end": 34,
"loc": {
@@ -135,12 +151,26 @@
"end": {
"line": 3,
"column": 11
},
"identifierName": "y"
}
},
"name": "y"
"id": {
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "y"
},
"name": "y"
}
},
"static": true,
"value": {
"type": "NumericLiteral",
"start": 37,
@@ -168,4 +198,4 @@
],
"directives": []
}
}
}