in src/utils/resolveToValue.ts [14:62]
function findScopePath(
paths: NodePath[],
path: NodePath,
importer: Importer,
): NodePath | null {
if (paths.length < 1) {
return null;
}
let resultPath = paths[0];
const parentPath = resultPath.parent;
// Namespace imports are handled separately, at the site of a member expression access
if (
t.ImportDefaultSpecifier.check(parentPath.node) ||
t.ImportSpecifier.check(parentPath.node)
) {
let exportName;
if (t.ImportDefaultSpecifier.check(parentPath.node)) {
exportName = 'default';
} else {
exportName = parentPath.node.imported.name;
}
const resolvedPath = importer(parentPath.parentPath, exportName);
if (resolvedPath) {
return resolveToValue(resolvedPath, importer);
}
}
if (
t.ImportDefaultSpecifier.check(parentPath.node) ||
t.ImportSpecifier.check(parentPath.node) ||
t.ImportNamespaceSpecifier.check(parentPath.node) ||
t.VariableDeclarator.check(parentPath.node) ||
t.TypeAlias.check(parentPath.node) ||
t.InterfaceDeclaration.check(parentPath.node) ||
t.TSTypeAliasDeclaration.check(parentPath.node) ||
t.TSInterfaceDeclaration.check(parentPath.node)
) {
resultPath = parentPath;
}
if (resultPath.node !== path.node) {
return resolveToValue(resultPath, importer);
}
return null;
}