Fix Flow return types on arrow functions (#124)
* fix: arrow return type on next line is valid https://github.com/babel/babel-eslint/issues/348 * fix: arrow on line after return type annotation is invalid * lint
This commit is contained in:
committed by
Daniel Tschinder
parent
abf6ca8e5e
commit
dc3036627b
@@ -577,7 +577,7 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
|
||||
this.expect(tt.parenR);
|
||||
|
||||
let arrowNode = this.startNodeAt(startPos, startLoc);
|
||||
if (canBeArrow && !this.canInsertSemicolon() && (arrowNode = this.parseArrow(arrowNode))) {
|
||||
if (canBeArrow && this.shouldParseArrow() && (arrowNode = this.parseArrow(arrowNode))) {
|
||||
for (let param of exprList) {
|
||||
if (param.extra && param.extra.parenthesized) this.unexpected(param.extra.parenStart);
|
||||
}
|
||||
@@ -613,6 +613,10 @@ pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow
|
||||
return val;
|
||||
};
|
||||
|
||||
pp.shouldParseArrow = function () {
|
||||
return !this.canInsertSemicolon();
|
||||
};
|
||||
|
||||
pp.parseArrow = function (node) {
|
||||
if (this.eat(tt.arrow)) {
|
||||
return node;
|
||||
|
||||
Reference in New Issue
Block a user