Skip to content

Commit b34977a

Browse files
motiz88danez
authored andcommitted
fix(traverse): only visit paths, not nodes
Traversing nodes detaches the resulting paths from the root File node, so they can end up crashing getFlowType which needs to grab the source code from the File.
1 parent ff7bed1 commit b34977a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/utils/resolveToValue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function findScopePath(paths: Array<NodePath>, path: NodePath): ?NodePath {
7575
function findLastAssignedValue(scope, name) {
7676
const results = [];
7777

78-
traverseShallow(scope.path.node, {
78+
traverseShallow(scope.path, {
7979
visitAssignmentExpression: function(path) {
8080
const node = path.node;
8181
// Skip anything that is not an assignment to a variable with the

src/utils/traverse.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ type Visitor = (path: NodePath) => any;
1616
* default.
1717
*/
1818
export function traverseShallow(
19-
ast: ASTNode,
19+
path: NodePath,
2020
visitors: { [key: string]: Visitor },
2121
): void {
22-
visit(ast, { ...defaultVisitors, ...visitors });
22+
visit(path, { ...defaultVisitors, ...visitors });
2323
}
2424

2525
const ignore = () => false;

0 commit comments

Comments
 (0)