Add the decoratorsAutoAccessors parser plugin (#13681)
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com> Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
committed by
Nicolò Ribaudo
parent
dc5f419fa9
commit
3f3ce5f668
3
packages/babel-parser/test/fixtures/experimental/_no-plugin/auto-accessors/input.js
vendored
Normal file
3
packages/babel-parser/test/fixtures/experimental/_no-plugin/auto-accessors/input.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor bar;
|
||||
}
|
||||
4
packages/babel-parser/test/fixtures/experimental/_no-plugin/auto-accessors/options.json
vendored
Normal file
4
packages/babel-parser/test/fixtures/experimental/_no-plugin/auto-accessors/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "This experimental syntax requires enabling the parser plugin: \"decoratorAutoAccessors\". (2:11)",
|
||||
"plugins": []
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor constructor;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Classes may not have a field named 'constructor'. (2:11)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":37,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":35,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":23}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":34,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":22},"identifierName":"constructor"},
|
||||
"name": "constructor"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
accessor
|
||||
bar;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"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":31,"loc":{"start":{"line":1,"column":10},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":14,"end":22,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":14,"end":22,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10},"identifierName":"accessor"},
|
||||
"name": "accessor"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":25,"end":29,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":6}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":25,"end":28,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor bar;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":29,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":27,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":15}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":26,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":14},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor ["constructor"];
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":41,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":41,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":39,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":27}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "StringLiteral",
|
||||
"start":24,"end":37,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":25}},
|
||||
"extra": {
|
||||
"rawValue": "constructor",
|
||||
"raw": "\"constructor\""
|
||||
},
|
||||
"value": "constructor"
|
||||
},
|
||||
"computed": true,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
accessor
|
||||
["bar"];
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"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":35,"loc":{"start":{"line":1,"column":10},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":14,"end":22,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":14,"end":22,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10},"identifierName":"accessor"},
|
||||
"name": "accessor"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":25,"end":33,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":10}},
|
||||
"static": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "StringLiteral",
|
||||
"start":26,"end":31,"loc":{"start":{"line":3,"column":3},"end":{"line":3,"column":8}},
|
||||
"extra": {
|
||||
"rawValue": "bar",
|
||||
"raw": "\"bar\""
|
||||
},
|
||||
"value": "bar"
|
||||
},
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor ["bar"];
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":33,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":33,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":31,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":19}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "StringLiteral",
|
||||
"start":24,"end":29,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":17}},
|
||||
"extra": {
|
||||
"rawValue": "bar",
|
||||
"raw": "\"bar\""
|
||||
},
|
||||
"value": "bar"
|
||||
},
|
||||
"computed": true,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
static accessor ["bar"];
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":40,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":40,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":38,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":26}},
|
||||
"static": true,
|
||||
"key": {
|
||||
"type": "StringLiteral",
|
||||
"start":31,"end":36,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":24}},
|
||||
"extra": {
|
||||
"rawValue": "bar",
|
||||
"raw": "\"bar\""
|
||||
},
|
||||
"value": "bar"
|
||||
},
|
||||
"computed": true,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor = 123;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":31,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":14,"end":29,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":14,"end":22,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10},"identifierName":"accessor"},
|
||||
"name": "accessor"
|
||||
},
|
||||
"computed": false,
|
||||
"value": {
|
||||
"type": "NumericLiteral",
|
||||
"start":25,"end":28,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":16}},
|
||||
"extra": {
|
||||
"rawValue": 123,
|
||||
"raw": "123"
|
||||
},
|
||||
"value": 123
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor static bar;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Missing semicolon. (2:17)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":36,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":29,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":29,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":17},"identifierName":"static"},
|
||||
"name": "static"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":30,"end":34,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":22}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":30,"end":33,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":21},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor static bar;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Missing semicolon. (2:17)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":36,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":29,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":29,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":17},"identifierName":"static"},
|
||||
"name": "static"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":30,"end":34,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":22}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":30,"end":33,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":21},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor() {}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":29,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":14,"end":27,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":15}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":14,"end":22,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":10},"identifierName":"accessor"},
|
||||
"name": "accessor"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":25,"end":27,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":15}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
accessor bar() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:14)"
|
||||
}
|
||||
5
packages/babel-parser/test/fixtures/experimental/decorator-auto-accessors/options.json
vendored
Normal file
5
packages/babel-parser/test/fixtures/experimental/decorator-auto-accessors/options.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"plugins": [
|
||||
"decoratorAutoAccessors"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
accessor #bar;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":30,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":30,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":28,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":16}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "PrivateName",
|
||||
"start":23,"end":27,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":15}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":24,"end":27,"loc":{"start":{"line":2,"column":12},"end":{"line":2,"column":15},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
static accessor #bar;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":37,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":37,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":35,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":23}},
|
||||
"static": true,
|
||||
"key": {
|
||||
"type": "PrivateName",
|
||||
"start":30,"end":34,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":22}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":31,"end":34,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":22},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
}
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
static accessor
|
||||
bar;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":38,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"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":38,"loc":{"start":{"line":1,"column":10},"end":{"line":4,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":14,"end":29,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}},
|
||||
"static": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":21,"end":29,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":17},"identifierName":"accessor"},
|
||||
"name": "accessor"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":32,"end":36,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":6}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":32,"end":35,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
static accessor bar;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "script",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":36,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"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":36,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassAccessorProperty",
|
||||
"start":14,"end":34,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}},
|
||||
"static": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":30,"end":33,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":21},"identifierName":"bar"},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false,
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user