Constructors

  • This searches the current "scope" and collects all references/bindings within.

    Parameters

    Returns Scope

Properties

bindings: {
    [name: string]: Binding;
}

Type declaration

block: Node
crawling: boolean
data: Record<string | symbol, unknown>
globals: {
    [name: string]: Identifier | JSXIdentifier;
}

Type declaration

labels: Map<string, NodePath<LabeledStatement>>
parent: Scope
parentBlock: Node
path: NodePath<Node>
references: {
    [name: string]: true;
}

Type declaration

  • [name: string]: true
uid: number
uids: {
    [name: string]: boolean;
}

Type declaration

  • [name: string]: boolean
contextVariables: string[]

Variables available in current context.

globals: string[]

Methods

  • Parameters

    Returns void

  • Parameters

    • name: string
    • node: Node

    Returns boolean

  • Parameters

    Returns void

  • Returns void

  • Returns void

  • Generate a unique identifier and add it to the current scope.

    Parameters

    • Optional name: string

    Returns Identifier

  • Generate a unique _id1 binding.

    Parameters

    • Optional name: string

    Returns string

  • Generate a unique identifier.

    Parameters

    • Optional name: string

    Returns Identifier

  • Generate a unique identifier based on a node.

    Parameters

    • parent: Node
    • Optional defaultName: string

    Returns Identifier

  • Walks the scope tree and gathers all bindings.

    Returns Record<string, Binding>

  • Walks the scope tree and gathers all declarations of kind.

    Parameters

    • Rest ...kinds: string[]

    Returns Record<string, Binding>

  • Parameters

    • name: string

    Returns undefined | Binding

  • Parameters

    • name: string

    Returns Identifier

  • Walk up the scope tree until we hit either a BlockStatement/Loop/Program/Function/Switch or reach the very top and hit Program.

    Returns Scope

  • Recursively walk up scope tree looking for the data key.

    Parameters

    • key: string

    Returns any

  • Walk up the scope tree until we hit either a Function or return null.

    Returns null | Scope

  • Parameters

    • name: string

    Returns undefined | Binding

  • Parameters

    • name: string

    Returns Identifier

  • Walk up from a pattern scope (function param initializer) until we hit a non-pattern scope, then returns its block parent

    Returns Scope

    An ancestry scope whose path is a block parent

  • Walk up to the top of the scope tree and get the Program.

    Returns Scope

  • Parameters

    • name: string
    • Optional optsOrNoGlobals: boolean | {
          noGlobals?: boolean;
          noUids?: boolean;
      }

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • name: string

    Returns boolean

  • Parameters

    • node: Node
    • Optional constantsOnly: boolean

    Returns boolean

  • Determine whether evaluating the specific input node is a consequenceless reference. ie. evaluating it wont result in potentially arbitrary code from being ran. The following are whitelisted and determined not to cause side effects:

    • this expressions
    • super expressions
    • Bound identifiers

    Parameters

    Returns boolean

  • Possibly generate a memoised identifier if it is not static and has consequences.

    Parameters

    • node: Node
    • Optional dontPush: boolean

    Returns Identifier

  • Move a binding of name to another scope.

    Parameters

    Returns void

  • Parameters

    • name: string
    • Optional opts: {
          noGlobals?: boolean;
          noUids?: boolean;
      }
      • Optional noGlobals?: boolean
      • Optional noUids?: boolean

    Returns boolean

  • Parameters

    • opts: {
          _blockHoist?: number;
          id: LVal;
          init?: Expression;
          kind?: "var" | "let" | "const";
          unique?: boolean;
      }
      • Optional _blockHoist?: number
      • id: LVal
      • Optional init?: Expression
      • Optional kind?: "var" | "let" | "const"
      • Optional unique?: boolean

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • name: string

    Returns void

  • Recursively walk up scope tree looking for the data key and if it exists, remove it.

    Parameters

    • key: string

    Returns void

  • Parameters

    • name: string

    Returns void

  • Parameters

    • oldName: string
    • Optional newName: string
    • Optional block: Node

    Returns void

  • Set some arbitrary data on the current scope.

    Parameters

    • key: string
    • val: any

    Returns any

  • Traverse node with current scope and path.

    Type Parameters

    • S

    Parameters

    Returns void

  • Parameters

    Returns void