Fix parsing of class properties (#351)
This commit is contained in:
parent
0b7da509d9
commit
81056eeee7
@ -625,11 +625,18 @@ pp.parseClass = function (node, isStatement, optionalId) {
|
||||
};
|
||||
|
||||
pp.isClassProperty = function () {
|
||||
return this.match(tt.eq) || this.isLineTerminator();
|
||||
return this.match(tt.eq) || this.match(tt.semi) || this.match(tt.braceR);
|
||||
};
|
||||
|
||||
pp.isClassMutatorStarter = function () {
|
||||
return false;
|
||||
pp.isClassMethod = function () {
|
||||
return this.match(tt.parenL);
|
||||
};
|
||||
|
||||
pp.isNonstaticConstructor = function (method) {
|
||||
return !method.computed && !method.static && (
|
||||
(method.key.name === "constructor") || // Identifier
|
||||
(method.key.value === "constructor") // Literal
|
||||
);
|
||||
};
|
||||
|
||||
pp.parseClassBody = function (node) {
|
||||
@ -667,92 +674,102 @@ pp.parseClassBody = function (node) {
|
||||
decorators = [];
|
||||
}
|
||||
|
||||
let isConstructorCall = false;
|
||||
const isMaybeStatic = this.match(tt.name) && this.state.value === "static";
|
||||
let isGenerator = this.eat(tt.star);
|
||||
let isGetSet = false;
|
||||
let isAsync = false;
|
||||
|
||||
this.parsePropertyName(method);
|
||||
|
||||
method.static = isMaybeStatic && !this.match(tt.parenL);
|
||||
if (method.static) {
|
||||
isGenerator = this.eat(tt.star);
|
||||
this.parsePropertyName(method);
|
||||
}
|
||||
|
||||
if (!isGenerator) {
|
||||
if (this.isClassProperty()) {
|
||||
method.static = false;
|
||||
if (this.match(tt.name) && this.state.value === "static") {
|
||||
const key = this.parseIdentifier(true); // eats 'static'
|
||||
if (this.isClassMethod()) {
|
||||
// a method named 'static'
|
||||
method.kind = "method";
|
||||
method.computed = false;
|
||||
method.key = key;
|
||||
this.parseClassMethod(classBody, method, false, false);
|
||||
continue;
|
||||
} else if (this.isClassProperty()) {
|
||||
// a property named 'static'
|
||||
method.computed = false;
|
||||
method.key = key;
|
||||
classBody.body.push(this.parseClassProperty(method));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (method.key.type === "Identifier" && !method.computed && this.hasPlugin("classConstructorCall") && method.key.name === "call" && this.match(tt.name) && this.state.value === "constructor") {
|
||||
isConstructorCall = true;
|
||||
this.parsePropertyName(method);
|
||||
}
|
||||
// otherwise something static
|
||||
method.static = true;
|
||||
}
|
||||
|
||||
const isAsyncMethod = !this.match(tt.parenL) && !method.computed && method.key.type === "Identifier" && method.key.name === "async";
|
||||
if (isAsyncMethod) {
|
||||
if (this.hasPlugin("asyncGenerators") && this.eat(tt.star)) isGenerator = true;
|
||||
isAsync = true;
|
||||
if (this.eat(tt.star)) {
|
||||
// a generator
|
||||
method.kind = "method";
|
||||
this.parsePropertyName(method);
|
||||
}
|
||||
|
||||
method.kind = "method";
|
||||
|
||||
if (!method.computed) {
|
||||
let { key } = method;
|
||||
|
||||
// handle get/set methods
|
||||
// eg. class Foo { get bar() {} set bar() {} }
|
||||
if (!isAsync && !isGenerator && !this.isClassMutatorStarter() && key.type === "Identifier" && !this.match(tt.parenL) && (key.name === "get" || key.name === "set")) {
|
||||
isGetSet = true;
|
||||
if (this.isNonstaticConstructor(method)) {
|
||||
this.raise(method.key.start, "Constructor can't be a generator");
|
||||
}
|
||||
if (!method.computed && method.static && (method.key.name === "prototype" || method.key.value === "prototype")) {
|
||||
this.raise(method.key.start, "Classes may not have static property named prototype");
|
||||
}
|
||||
this.parseClassMethod(classBody, method, true, false);
|
||||
} else {
|
||||
const isSimple = this.match(tt.name);
|
||||
const key = this.parsePropertyName(method);
|
||||
if (!method.computed && method.static && (method.key.name === "prototype" || method.key.value === "prototype")) {
|
||||
this.raise(method.key.start, "Classes may not have static property named prototype");
|
||||
}
|
||||
if (this.isClassMethod()) {
|
||||
// a normal method
|
||||
if (this.isNonstaticConstructor(method)) {
|
||||
if (hadConstructor) {
|
||||
this.raise(key.start, "Duplicate constructor in the same class");
|
||||
} else if (method.decorators) {
|
||||
this.raise(method.start, "You can't attach decorators to a class constructor");
|
||||
}
|
||||
hadConstructor = true;
|
||||
method.kind = "constructor";
|
||||
} else {
|
||||
method.kind = "method";
|
||||
}
|
||||
this.parseClassMethod(classBody, method, false, false);
|
||||
} else if (this.isClassProperty()) {
|
||||
// a normal property
|
||||
if (this.isNonstaticConstructor(method)) {
|
||||
this.raise(method.key.start, "Classes may not have a non-static field named 'constructor'");
|
||||
}
|
||||
classBody.body.push(this.parseClassProperty(method));
|
||||
} else if (isSimple && key.name === "async" && !this.isLineTerminator()) {
|
||||
// an async method
|
||||
const isGenerator = this.hasPlugin("asyncGenerators") && this.eat(tt.star);
|
||||
method.kind = "method";
|
||||
this.parsePropertyName(method);
|
||||
if (this.isNonstaticConstructor(method)) {
|
||||
this.raise(method.key.start, "Constructor can't be an async function");
|
||||
}
|
||||
this.parseClassMethod(classBody, method, isGenerator, true);
|
||||
} else if (isSimple && (key.name === "get" || key.name === "set") && !(this.isLineTerminator() && this.match(tt.star))) { // `get\n*` is an uninitialized property named 'get' followed by a generator.
|
||||
// a getter or setter
|
||||
method.kind = key.name;
|
||||
key = this.parsePropertyName(method);
|
||||
this.parsePropertyName(method);
|
||||
if (this.isNonstaticConstructor(method)) {
|
||||
this.raise(method.key.start, "Constructor can't have get/set modifier");
|
||||
}
|
||||
this.parseClassMethod(classBody, method, false, false);
|
||||
this.checkGetterSetterParamCount(method);
|
||||
} else if (this.hasPlugin("classConstructorCall") && isSimple && key.name === "call" && this.match(tt.name) && this.state.value === "constructor") {
|
||||
// a (deprecated) call constructor
|
||||
if (hadConstructorCall) {
|
||||
this.raise(method.start, "Duplicate constructor call in the same class");
|
||||
} else if (method.decorators) {
|
||||
this.raise(method.start, "You can't attach decorators to a class constructor");
|
||||
}
|
||||
hadConstructorCall = true;
|
||||
method.kind = "constructorCall";
|
||||
this.parsePropertyName(method); // consume "constructor" and make it the method's name
|
||||
this.parseClassMethod(classBody, method, false, false);
|
||||
} else if (this.isLineTerminator()) {
|
||||
// an uninitialized class property (due to ASI, since we don't otherwise recognize the next token)
|
||||
if (this.isNonstaticConstructor(method)) {
|
||||
this.raise(method.key.start, "Classes may not have a non-static field named 'constructor'");
|
||||
}
|
||||
classBody.body.push(this.parseClassProperty(method));
|
||||
} else {
|
||||
this.unexpected();
|
||||
}
|
||||
|
||||
// disallow invalid constructors
|
||||
const isConstructor = !isConstructorCall && !method.static && (
|
||||
(key.name === "constructor") || // Identifier
|
||||
(key.value === "constructor") // Literal
|
||||
);
|
||||
if (isConstructor) {
|
||||
if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class");
|
||||
if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier");
|
||||
if (isGenerator) this.raise(key.start, "Constructor can't be a generator");
|
||||
if (isAsync) this.raise(key.start, "Constructor can't be an async function");
|
||||
method.kind = "constructor";
|
||||
hadConstructor = true;
|
||||
}
|
||||
|
||||
// disallow static prototype method
|
||||
const isStaticPrototype = method.static && (
|
||||
(key.name === "prototype") || // Identifier
|
||||
(key.value === "prototype") // Literal
|
||||
);
|
||||
if (isStaticPrototype) {
|
||||
this.raise(key.start, "Classes may not have static property named prototype");
|
||||
}
|
||||
}
|
||||
|
||||
// convert constructor to a constructor call
|
||||
if (isConstructorCall) {
|
||||
if (hadConstructorCall) this.raise(method.start, "Duplicate constructor call in the same class");
|
||||
method.kind = "constructorCall";
|
||||
hadConstructorCall = true;
|
||||
}
|
||||
|
||||
// disallow decorators on class constructors
|
||||
if ((method.kind === "constructor" || method.kind === "constructorCall") && method.decorators) {
|
||||
this.raise(method.start, "You can't attach decorators to a class constructor");
|
||||
}
|
||||
|
||||
this.parseClassMethod(classBody, method, isGenerator, isAsync);
|
||||
|
||||
if (isGetSet) {
|
||||
this.checkGetterSetterParamCount(method);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1109,6 +1109,13 @@ export default function (instance) {
|
||||
};
|
||||
});
|
||||
|
||||
// determine whether or not we're currently in the position where a class method would appear
|
||||
instance.extend("isClassMethod", function (inner) {
|
||||
return function () {
|
||||
return this.isRelational("<") || inner.call(this);
|
||||
};
|
||||
});
|
||||
|
||||
// determine whether or not we're currently in the position where a class property would appear
|
||||
instance.extend("isClassProperty", function (inner) {
|
||||
return function () {
|
||||
@ -1439,14 +1446,4 @@ export default function (instance) {
|
||||
return this.match(tt.colon) || inner.call(this);
|
||||
};
|
||||
});
|
||||
|
||||
instance.extend("isClassMutatorStarter", function (inner) {
|
||||
return function () {
|
||||
if (this.isRelational("<")) {
|
||||
return true;
|
||||
} else {
|
||||
return inner.call(this);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
3
test/fixtures/es2015/class-methods/disallow-static-generator-prototype/actual.js
vendored
Normal file
3
test/fixtures/es2015/class-methods/disallow-static-generator-prototype/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class A {
|
||||
static *prototype() {}
|
||||
}
|
||||
3
test/fixtures/es2015/class-methods/disallow-static-generator-prototype/options.json
vendored
Normal file
3
test/fixtures/es2015/class-methods/disallow-static-generator-prototype/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Classes may not have static property named prototype (2:10)"
|
||||
}
|
||||
42
test/fixtures/es2015/class-methods/linebreaks/actual.js
vendored
Normal file
42
test/fixtures/es2015/class-methods/linebreaks/actual.js
vendored
Normal 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
|
||||
() {}
|
||||
}
|
||||
690
test/fixtures/es2015/class-methods/linebreaks/expected.json
vendored
Normal file
690
test/fixtures/es2015/class-methods/linebreaks/expected.json
vendored
Normal 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": []
|
||||
}
|
||||
}
|
||||
45
test/fixtures/es2015/class-methods/tricky-names/actual.js
vendored
Normal file
45
test/fixtures/es2015/class-methods/tricky-names/actual.js
vendored
Normal 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
|
||||
() {}
|
||||
}
|
||||
711
test/fixtures/es2015/class-methods/tricky-names/expected.json
vendored
Normal file
711
test/fixtures/es2015/class-methods/tricky-names/expected.json
vendored
Normal 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": []
|
||||
}
|
||||
}
|
||||
4
test/fixtures/es2017/async-functions/no-method-asi/actual.js
vendored
Normal file
4
test/fixtures/es2017/async-functions/no-method-asi/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class A {
|
||||
async
|
||||
a(){}
|
||||
}
|
||||
3
test/fixtures/es2017/async-functions/no-method-asi/options.json
vendored
Normal file
3
test/fixtures/es2017/async-functions/no-method-asi/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ( (1:10)"
|
||||
"throws": "Unexpected token (1:10)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ( (1:11)"
|
||||
"throws": "Unexpected token (1:11)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ( (1:23)"
|
||||
"throws": "Unexpected token (1:23)"
|
||||
}
|
||||
|
||||
4
test/fixtures/experimental/async-generators/class-method-2/actual.js
vendored
Normal file
4
test/fixtures/experimental/async-generators/class-method-2/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class A {
|
||||
async *
|
||||
a(){}
|
||||
}
|
||||
141
test/fixtures/experimental/async-generators/class-method-2/expected.json
vendored
Normal file
141
test/fixtures/experimental/async-generators/class-method-2/expected.json
vendored
Normal 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": []
|
||||
}
|
||||
}
|
||||
4
test/fixtures/experimental/async-generators/class-method-no-asi/actual.js
vendored
Normal file
4
test/fixtures/experimental/async-generators/class-method-no-asi/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class A {
|
||||
async
|
||||
* a(){}
|
||||
}
|
||||
3
test/fixtures/experimental/async-generators/class-method-no-asi/options.json
vendored
Normal file
3
test/fixtures/experimental/async-generators/class-method-no-asi/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "You can only use Class Properties when the 'classProperties' plugin is enabled. (2:2)"
|
||||
}
|
||||
4
test/fixtures/experimental/class-constructor-call/disallow-decorator/actual.js
vendored
Normal file
4
test/fixtures/experimental/class-constructor-call/disallow-decorator/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
@dec
|
||||
call constructor() {}
|
||||
}
|
||||
4
test/fixtures/experimental/class-constructor-call/disallow-decorator/options.json
vendored
Normal file
4
test/fixtures/experimental/class-constructor-call/disallow-decorator/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "You can't attach decorators to a class constructor (3:2)",
|
||||
"plugins": ["classConstructorCall", "decorators"]
|
||||
}
|
||||
4
test/fixtures/experimental/class-constructor-call/disallow-duplicate/actual.js
vendored
Normal file
4
test/fixtures/experimental/class-constructor-call/disallow-duplicate/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
call constructor() {}
|
||||
call constructor() {}
|
||||
}
|
||||
3
test/fixtures/experimental/class-constructor-call/disallow-duplicate/options.json
vendored
Normal file
3
test/fixtures/experimental/class-constructor-call/disallow-duplicate/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Duplicate constructor call in the same class (3:2)"
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token, expected ( (2:7)"
|
||||
"throws": "Unexpected token (2:7)"
|
||||
}
|
||||
|
||||
3
test/fixtures/experimental/class-properties/asi-failure-inline/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/asi-failure-inline/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
x y
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/asi-failure-inline/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/asi-failure-inline/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Unexpected token (2:4)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
50
test/fixtures/experimental/class-properties/edge-cases/actual.js
vendored
Normal file
50
test/fixtures/experimental/class-properties/edge-cases/actual.js
vendored
Normal 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
|
||||
(){}
|
||||
}
|
||||
1496
test/fixtures/experimental/class-properties/edge-cases/expected.json
vendored
Normal file
1496
test/fixtures/experimental/class-properties/edge-cases/expected.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
test/fixtures/experimental/class-properties/edge-cases/options.json
vendored
Normal file
3
test/fixtures/experimental/class-properties/edge-cases/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
3
test/fixtures/experimental/class-properties/inline/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/inline/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class A { x; y; }
|
||||
|
||||
class B { x = 0; y = 1; }
|
||||
312
test/fixtures/experimental/class-properties/inline/expected.json
vendored
Normal file
312
test/fixtures/experimental/class-properties/inline/expected.json
vendored
Normal 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": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/experimental/class-properties/inline/options.json
vendored
Normal file
3
test/fixtures/experimental/class-properties/inline/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/no-ctor-2/actual.js
vendored
Normal file
4
test/fixtures/experimental/class-properties/no-ctor-2/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
constructor
|
||||
*x(){}
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/no-ctor-2/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/no-ctor-2/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Classes may not have a non-static field named 'constructor' (2:2)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
3
test/fixtures/experimental/class-properties/no-ctor/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/no-ctor/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
constructor
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/no-ctor/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/no-ctor/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Classes may not have a non-static field named 'constructor' (2:2)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/no-static-prototype-2/actual.js
vendored
Normal file
4
test/fixtures/experimental/class-properties/no-static-prototype-2/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
static prototype
|
||||
*x(){}
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/no-static-prototype-2/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/no-static-prototype-2/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Classes may not have static property named prototype (2:9)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
3
test/fixtures/experimental/class-properties/no-static-prototype/actual.js
vendored
Normal file
3
test/fixtures/experimental/class-properties/no-static-prototype/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
static prototype
|
||||
}
|
||||
4
test/fixtures/experimental/class-properties/no-static-prototype/options.json
vendored
Normal file
4
test/fixtures/experimental/class-properties/no-static-prototype/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "Classes may not have static property named prototype (2:9)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
2
test/fixtures/experimental/decorators/export-decorators-on-class/actual.js
vendored
Normal file
2
test/fixtures/experimental/decorators/export-decorators-on-class/actual.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
@foo
|
||||
export default class {}
|
||||
116
test/fixtures/experimental/decorators/export-decorators-on-class/expected.json
vendored
Normal file
116
test/fixtures/experimental/decorators/export-decorators-on-class/expected.json
vendored
Normal 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": []
|
||||
}
|
||||
}
|
||||
3
test/fixtures/experimental/decorators/export-decorators-on-class/options.json
vendored
Normal file
3
test/fixtures/experimental/decorators/export-decorators-on-class/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"sourceType": "module"
|
||||
}
|
||||
4
test/fixtures/experimental/decorators/no-constructor-decorators/actual.js
vendored
Normal file
4
test/fixtures/experimental/decorators/no-constructor-decorators/actual.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
@abc
|
||||
constructor(){}
|
||||
}
|
||||
3
test/fixtures/experimental/decorators/no-constructor-decorators/options.json
vendored
Normal file
3
test/fixtures/experimental/decorators/no-constructor-decorators/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "You can't attach decorators to a class constructor (3:2)"
|
||||
}
|
||||
2
test/fixtures/experimental/decorators/no-export-decorators-without-class/actual.js
vendored
Normal file
2
test/fixtures/experimental/decorators/no-export-decorators-without-class/actual.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
@foo
|
||||
export default function f(){};
|
||||
4
test/fixtures/experimental/decorators/no-export-decorators-without-class/options.json
vendored
Normal file
4
test/fixtures/experimental/decorators/no-export-decorators-without-class/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "You can only use decorators on an export when exporting a class (2:0)",
|
||||
"sourceType": "module"
|
||||
}
|
||||
2
test/fixtures/experimental/decorators/no-export-decorators/actual.js
vendored
Normal file
2
test/fixtures/experimental/decorators/no-export-decorators/actual.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
@foo
|
||||
export default 0;
|
||||
4
test/fixtures/experimental/decorators/no-export-decorators/options.json
vendored
Normal file
4
test/fixtures/experimental/decorators/no-export-decorators/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "You can only use decorators on an export when exporting a class (2:0)",
|
||||
"sourceType": "module"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user