flow: allow generic method with name get or set

This commit is contained in:
Vladimir Kurchatkin
2016-06-24 19:47:30 +03:00
parent cde17b33bd
commit d5f75cb2f0
3 changed files with 323 additions and 1 deletions

View File

@@ -658,6 +658,7 @@ pp.parseClassBody = function (node) {
let isGenerator = this.eat(tt.star);
let isGetSet = false;
let isAsync = false;
let isGeneric = false;
this.parsePropertyName(method);
@@ -692,9 +693,13 @@ pp.parseClassBody = function (node) {
if (!method.computed) {
let { key } = method;
if (this.hasPlugin("flow") && this.isRelational("<")) {
isGeneric = true;
}
// handle get/set methods
// eg. class Foo { get bar() {} set bar() {} }
if (!isAsync && !isGenerator && key.type === "Identifier" && !this.match(tt.parenL) && (key.name === "get" || key.name === "set")) {
if (!isAsync && !isGenerator && !isGeneric && key.type === "Identifier" && !this.match(tt.parenL) && (key.name === "get" || key.name === "set")) {
isGetSet = true;
method.kind = key.name;
key = this.parsePropertyName(method);