Fix rest parameters with flow type casting (#4636)
Do not skip TypeCastExpressions when finding referenced identifiers as the type cast contains valid non flow code that we need to visit.
This commit is contained in:
committed by
Henry Zhu
parent
fe2b9d73ed
commit
16716ea3de
@@ -30,6 +30,8 @@ let memberExpressionOptimisationVisitor = {
|
||||
},
|
||||
|
||||
Flow(path) {
|
||||
// Do not skip TypeCastExpressions as the contain valid non flow code
|
||||
if (path.isTypeCastExpression()) return;
|
||||
// don't touch reference in type annotations
|
||||
path.skip();
|
||||
},
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
let oneOf = (...nodes) => {
|
||||
if (nodes.length === 1) {
|
||||
return nodes[0];
|
||||
}
|
||||
return ((new OneOfNode(nodes)): any)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
let oneOf = function () {
|
||||
for (var _len = arguments.length, nodes = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
nodes[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
if (nodes.length === 1) {
|
||||
return nodes[0];
|
||||
}
|
||||
return new OneOfNode(nodes);
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["syntax-flow", "transform-flow-strip-types", "transform-es2015-parameters", "transform-es2015-destructuring", "transform-es2015-arrow-functions"]
|
||||
}
|
||||
Reference in New Issue
Block a user