babel-type-scopes
Utils for looking up and working with Flow & TypeScript scopes in Babel
Last updated 8 years ago by thejameskyle .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-type-scopes 
SYNC missed versions from official npm registry.

babel-type-scopes

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 }

Installation

yarn add babel-type-scopes

API

isTypeScope(path: Path) => boolean

Check if a path creates a type scope.

getClosestTypeScope(path: Path) => Path

Find the closest path to a type scope.

getOwnTypeBindings(path: Path) => Bindings

Find the closest path to a type scope.

getTypeBinding(path: Path) => Binding

Search for a binding in the current scope and parent scopes.

Types

Binding

type Binding = {
  kind: 'import' | 'declaration' | 'expression' | 'param',
  path: Path,
  id: Path,
};

Bindings

type Bindings = { [name: string]: Binding };

Current Tags

  • 1.1.0                                ...           latest (8 years ago)

2 Versions

  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 2
Last Day 1
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |