Utils for looking up and working with Flow & TypeScript scopes in Babel
import {
isTypeScope,
getClosestTypeScopePath,
getOwnTypeBindings,
getTypeBinding,
} from 'babel-type-scopes';
isTypeScope(path); // true | false
getClosestTypeScopePath(path); // (Path)
getOwnTypeBindings(path) // { foo: { kind, path, id }, bar: { kind, path, id } }
getTypeBinding(path, 'foo') // { kind, path, id }
yarn add babel-type-scopes
Check if a path creates a type scope.
Find the closest path to a type scope.
Find the closest path to a type scope.
Search for a binding in the current scope and parent scopes.
type Binding = {
kind: 'import' | 'declaration' | 'expression' | 'param',
path: Path,
id: Path,
};
type Bindings = { [name: string]: Binding };