Fix push-pop logic in flow (#405)

This commit is contained in:
Daniel Tschinder 2017-03-22 10:25:10 +01:00 committed by GitHub
parent af5fdc2ebd
commit 32eabf620b

View File

@ -1377,10 +1377,10 @@ export default function (instance) {
}
}
// Need to push something onto the context to stop
// the JSX plugin from messing with the tokens
this.state.context.push(ct.parenExpression);
if (jsxError != null || this.isRelational("<")) {
// Need to push something onto the context to stop
// the JSX plugin from messing with the tokens
this.state.context.push(ct.parenExpression);
let arrowExpression;
let typeParameters;
try {
@ -1390,9 +1390,13 @@ export default function (instance) {
arrowExpression.typeParameters = typeParameters;
this.resetStartLocationFromNode(arrowExpression, typeParameters);
} catch (err) {
this.state.context.pop();
throw jsxError || err;
}
this.state.context.pop();
if (arrowExpression.type === "ArrowFunctionExpression") {
return arrowExpression;
} else if (jsxError != null) {
@ -1404,7 +1408,6 @@ export default function (instance) {
);
}
}
this.state.context.pop();
return inner.apply(this, args);
};