Fix parsing of class properties (#351)

This commit is contained in:
Kevin Gibbons
2017-03-10 03:43:45 -08:00
committed by Daniel Tschinder
parent 0b7da509d9
commit 81056eeee7
47 changed files with 3821 additions and 95 deletions

View File

@@ -0,0 +1,3 @@
class A {
static *prototype() {}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "Classes may not have static property named prototype (2:10)"
}

View File

@@ -0,0 +1,42 @@
class A {
get
a
() {}
set
a
(a) {}
constructor
() {}
a
() {}
*
a
() {}
static
get
a
() {}
static
set
a
(a) {}
static
constructor
() {}
static
a
() {}
static
*
a
() {}
}

View File

@@ -0,0 +1,690 @@
{
"type": "File",
"start": 0,
"end": 239,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 42,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 239,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 42,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 239,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 42,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 239,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 42,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 12,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 4,
"column": 7
}
},
"static": false,
"kind": "get",
"computed": false,
"key": {
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 25,
"end": 27,
"loc": {
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 31,
"end": 47,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 8,
"column": 8
}
},
"static": false,
"kind": "set",
"computed": false,
"key": {
"type": "Identifier",
"start": 37,
"end": 38,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 42,
"end": 43,
"loc": {
"start": {
"line": 8,
"column": 3
},
"end": {
"line": 8,
"column": 4
},
"identifierName": "a"
},
"name": "a"
}
],
"body": {
"type": "BlockStatement",
"start": 45,
"end": 47,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 8
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 51,
"end": 70,
"loc": {
"start": {
"line": 10,
"column": 2
},
"end": {
"line": 11,
"column": 7
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 51,
"end": 62,
"loc": {
"start": {
"line": 10,
"column": 2
},
"end": {
"line": 10,
"column": 13
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 68,
"end": 70,
"loc": {
"start": {
"line": 11,
"column": 5
},
"end": {
"line": 11,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 74,
"end": 83,
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 14,
"column": 7
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 74,
"end": 75,
"loc": {
"start": {
"line": 13,
"column": 2
},
"end": {
"line": 13,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 81,
"end": 83,
"loc": {
"start": {
"line": 14,
"column": 5
},
"end": {
"line": 14,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 87,
"end": 100,
"loc": {
"start": {
"line": 16,
"column": 2
},
"end": {
"line": 18,
"column": 7
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 91,
"end": 92,
"loc": {
"start": {
"line": 17,
"column": 2
},
"end": {
"line": 17,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"id": null,
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 98,
"end": 100,
"loc": {
"start": {
"line": 18,
"column": 5
},
"end": {
"line": 18,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 104,
"end": 128,
"loc": {
"start": {
"line": 20,
"column": 2
},
"end": {
"line": 23,
"column": 7
}
},
"static": true,
"kind": "get",
"computed": false,
"key": {
"type": "Identifier",
"start": 119,
"end": 120,
"loc": {
"start": {
"line": 22,
"column": 2
},
"end": {
"line": 22,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 126,
"end": 128,
"loc": {
"start": {
"line": 23,
"column": 5
},
"end": {
"line": 23,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 132,
"end": 157,
"loc": {
"start": {
"line": 25,
"column": 2
},
"end": {
"line": 28,
"column": 8
}
},
"static": true,
"kind": "set",
"computed": false,
"key": {
"type": "Identifier",
"start": 147,
"end": 148,
"loc": {
"start": {
"line": 27,
"column": 2
},
"end": {
"line": 27,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 152,
"end": 153,
"loc": {
"start": {
"line": 28,
"column": 3
},
"end": {
"line": 28,
"column": 4
},
"identifierName": "a"
},
"name": "a"
}
],
"body": {
"type": "BlockStatement",
"start": 155,
"end": 157,
"loc": {
"start": {
"line": 28,
"column": 6
},
"end": {
"line": 28,
"column": 8
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 161,
"end": 189,
"loc": {
"start": {
"line": 30,
"column": 2
},
"end": {
"line": 32,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 170,
"end": 181,
"loc": {
"start": {
"line": 31,
"column": 2
},
"end": {
"line": 31,
"column": 13
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 187,
"end": 189,
"loc": {
"start": {
"line": 32,
"column": 5
},
"end": {
"line": 32,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 193,
"end": 211,
"loc": {
"start": {
"line": 34,
"column": 2
},
"end": {
"line": 36,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 202,
"end": 203,
"loc": {
"start": {
"line": 35,
"column": 2
},
"end": {
"line": 35,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 209,
"end": 211,
"loc": {
"start": {
"line": 36,
"column": 5
},
"end": {
"line": 36,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 215,
"end": 237,
"loc": {
"start": {
"line": 38,
"column": 2
},
"end": {
"line": 41,
"column": 7
}
},
"static": true,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 228,
"end": 229,
"loc": {
"start": {
"line": 40,
"column": 2
},
"end": {
"line": 40,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"id": null,
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 235,
"end": 237,
"loc": {
"start": {
"line": 41,
"column": 5
},
"end": {
"line": 41,
"column": 7
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,45 @@
class A {
get
() {}
set
() {}
static
() {}
async
() {}
static
get
() {}
static
set
() {}
static
static
() {}
static
async
() {}
static
a
() {}
get
async
() {}
static
get
static
() {}
}

View File

@@ -0,0 +1,711 @@
{
"type": "File",
"start": 0,
"end": 257,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 45,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 257,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 45,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 257,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 45,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 257,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 45,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 3,
"column": 7
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 5
},
"identifierName": "get"
},
"name": "get"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 27,
"end": 38,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 6,
"column": 7
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 27,
"end": 30,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 5
},
"identifierName": "set"
},
"name": "set"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 36,
"end": 38,
"loc": {
"start": {
"line": 6,
"column": 5
},
"end": {
"line": 6,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 42,
"end": 56,
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 9,
"column": 7
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 42,
"end": 48,
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 8,
"column": 8
},
"identifierName": "static"
},
"name": "static"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 54,
"end": 56,
"loc": {
"start": {
"line": 9,
"column": 5
},
"end": {
"line": 9,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 60,
"end": 73,
"loc": {
"start": {
"line": 11,
"column": 2
},
"end": {
"line": 12,
"column": 7
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 60,
"end": 65,
"loc": {
"start": {
"line": 11,
"column": 2
},
"end": {
"line": 11,
"column": 7
},
"identifierName": "async"
},
"name": "async"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 71,
"end": 73,
"loc": {
"start": {
"line": 12,
"column": 5
},
"end": {
"line": 12,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 78,
"end": 98,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 17,
"column": 7
}
},
"static": true,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 87,
"end": 90,
"loc": {
"start": {
"line": 16,
"column": 2
},
"end": {
"line": 16,
"column": 5
},
"identifierName": "get"
},
"name": "get"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 96,
"end": 98,
"loc": {
"start": {
"line": 17,
"column": 5
},
"end": {
"line": 17,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 102,
"end": 122,
"loc": {
"start": {
"line": 19,
"column": 2
},
"end": {
"line": 21,
"column": 7
}
},
"static": true,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 111,
"end": 114,
"loc": {
"start": {
"line": 20,
"column": 2
},
"end": {
"line": 20,
"column": 5
},
"identifierName": "set"
},
"name": "set"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 120,
"end": 122,
"loc": {
"start": {
"line": 21,
"column": 5
},
"end": {
"line": 21,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 126,
"end": 149,
"loc": {
"start": {
"line": 23,
"column": 2
},
"end": {
"line": 25,
"column": 7
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 135,
"end": 141,
"loc": {
"start": {
"line": 24,
"column": 2
},
"end": {
"line": 24,
"column": 8
},
"identifierName": "static"
},
"name": "static"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 147,
"end": 149,
"loc": {
"start": {
"line": 25,
"column": 5
},
"end": {
"line": 25,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 153,
"end": 175,
"loc": {
"start": {
"line": 27,
"column": 2
},
"end": {
"line": 29,
"column": 7
}
},
"static": true,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 162,
"end": 167,
"loc": {
"start": {
"line": 28,
"column": 2
},
"end": {
"line": 28,
"column": 7
},
"identifierName": "async"
},
"name": "async"
},
"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,
"kind": "get",
"computed": false,
"key": {
"type": "Identifier",
"start": 208,
"end": 213,
"loc": {
"start": {
"line": 37,
"column": 2
},
"end": {
"line": 37,
"column": 7
},
"identifierName": "async"
},
"name": "async"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 219,
"end": 221,
"loc": {
"start": {
"line": 38,
"column": 5
},
"end": {
"line": 38,
"column": 7
}
},
"body": [],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 226,
"end": 255,
"loc": {
"start": {
"line": 41,
"column": 2
},
"end": {
"line": 44,
"column": 7
}
},
"static": true,
"kind": "get",
"computed": false,
"key": {
"type": "Identifier",
"start": 241,
"end": 247,
"loc": {
"start": {
"line": 43,
"column": 2
},
"end": {
"line": 43,
"column": 8
},
"identifierName": "static"
},
"name": "static"
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 253,
"end": 255,
"loc": {
"start": {
"line": 44,
"column": 5
},
"end": {
"line": 44,
"column": 7
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

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

View File

@@ -0,0 +1,3 @@
{
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
}

View File

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

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token, expected ( (1:11)"
"throws": "Unexpected token (1:11)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Unexpected token, expected ( (1:23)"
"throws": "Unexpected token (1:23)"
}

View File

@@ -0,0 +1,4 @@
class A {
async *
a(){}
}

View File

@@ -0,0 +1,141 @@
{
"type": "File",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 12,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 3,
"column": 7
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 22,
"end": 23,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 3
},
"identifierName": "a"
},
"name": "a"
},
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start": 25,
"end": 27,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 7
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,4 @@
class A {
async
* a(){}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
}

View File

@@ -0,0 +1,4 @@
class Foo {
@dec
call constructor() {}
}

View File

@@ -0,0 +1,4 @@
{
"throws": "You can't attach decorators to a class constructor (3:2)",
"plugins": ["classConstructorCall", "decorators"]
}

View File

@@ -0,0 +1,4 @@
class Foo {
call constructor() {}
call constructor() {}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "Duplicate constructor call in the same class (3:2)"
}

View File

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

View File

@@ -0,0 +1,3 @@
class Foo {
x y
}

View File

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

View File

@@ -0,0 +1,50 @@
class A1 {
static
a
static
}
class A2 { a }
class A3 { get }
class A4 { set }
class A5 { static }
class A6 { async }
class A7 {
get
*a(){}
}
class A8 {
static
*a(){}
}
class A9 {
async
a(){}
}
class A10 {
static
async
a
}
class A11 { static; }
class A12 {
static = 0;
}
class A13 {
get
['a'](){}
}
class A14 {
static
get
static
(){}
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,3 @@
class A { x; y; }
class B { x = 0; y = 1; }

View File

@@ -0,0 +1,312 @@
{
"type": "File",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 25
}
},
"program": {
"type": "Program",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 25
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 17
}
},
"body": [
{
"type": "ClassProperty",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "x"
},
"name": "x"
},
"value": null
},
{
"type": "ClassProperty",
"start": 13,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 15
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "y"
},
"name": "y"
},
"value": null
}
]
}
},
{
"type": "ClassDeclaration",
"start": 19,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 7
},
"identifierName": "B"
},
"name": "B"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 27,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 25
}
},
"body": [
{
"type": "ClassProperty",
"start": 29,
"end": 35,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 16
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "x"
},
"name": "x"
},
"value": {
"type": "NumericLiteral",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "ClassProperty",
"start": 36,
"end": 42,
"loc": {
"start": {
"line": 3,
"column": 17
},
"end": {
"line": 3,
"column": 23
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 36,
"end": 37,
"loc": {
"start": {
"line": 3,
"column": 17
},
"end": {
"line": 3,
"column": 18
},
"identifierName": "y"
},
"name": "y"
},
"value": {
"type": "NumericLiteral",
"start": 40,
"end": 41,
"loc": {
"start": {
"line": 3,
"column": 21
},
"end": {
"line": 3,
"column": 22
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
]
}
}
],
"directives": []
}
}

View File

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

View File

@@ -0,0 +1,4 @@
class Foo {
constructor
*x(){}
}

View File

@@ -0,0 +1,4 @@
{
"throws": "Classes may not have a non-static field named 'constructor' (2:2)",
"plugins": ["classProperties"]
}

View File

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

View File

@@ -0,0 +1,4 @@
{
"throws": "Classes may not have a non-static field named 'constructor' (2:2)",
"plugins": ["classProperties"]
}

View File

@@ -0,0 +1,4 @@
class Foo {
static prototype
*x(){}
}

View File

@@ -0,0 +1,4 @@
{
"throws": "Classes may not have static property named prototype (2:9)",
"plugins": ["classProperties"]
}

View File

@@ -0,0 +1,3 @@
class Foo {
static prototype
}

View File

@@ -0,0 +1,4 @@
{
"throws": "Classes may not have static property named prototype (2:9)",
"plugins": ["classProperties"]
}

View File

@@ -0,0 +1,2 @@
@foo
export default class {}

View File

@@ -0,0 +1,116 @@
{
"type": "File",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 23
}
},
"sourceType": "module",
"body": [
{
"type": "ExportDefaultDeclaration",
"start": 5,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 23
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 20,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 23
}
},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start": 26,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 23
}
},
"body": []
},
"decorators": [
{
"type": "Decorator",
"start": 0,
"end": 4,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
},
"expression": {
"type": "Identifier",
"start": 1,
"end": 4,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 4
},
"identifierName": "foo"
},
"name": "foo"
}
}
]
}
}
],
"directives": []
}
}

View File

@@ -0,0 +1,3 @@
{
"sourceType": "module"
}

View File

@@ -0,0 +1,4 @@
class Foo {
@abc
constructor(){}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "You can't attach decorators to a class constructor (3:2)"
}

View File

@@ -0,0 +1,2 @@
@foo
export default function f(){};

View File

@@ -0,0 +1,4 @@
{
"throws": "You can only use decorators on an export when exporting a class (2:0)",
"sourceType": "module"
}

View File

@@ -0,0 +1,2 @@
@foo
export default 0;

View File

@@ -0,0 +1,4 @@
{
"throws": "You can only use decorators on an export when exporting a class (2:0)",
"sourceType": "module"
}