UNPKG

estree-toolkit

Version:

Traverser, scope tracker, and more tools for working with ESTree AST

47 lines (46 loc) 2.02 kB
import { CatchClause, ClassDeclaration, ClassExpression, FunctionDeclaration, FunctionExpression, Identifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXIdentifier, Pattern, VariableDeclarator } from 'estree-jsx'; import { NodePath } from './nodepath'; import { Scope } from './scope'; declare class BaseBinding { readonly references: NodePath<Identifier | JSXIdentifier>[]; readonly constantViolations: NodePath<Identifier>[]; addReference(path: NodePath<Identifier | JSXIdentifier>): void; removeReference(path: NodePath<Identifier | JSXIdentifier>): void; addConstantViolation(path: NodePath<Identifier>): void; removeConstantViolation(path: NodePath<Identifier>): void; } export type BindingKind = 'var' | 'let' | 'const' | 'param' | 'unknown' | 'hoisted' | 'local' | 'module'; export type BindingPathT<T extends BindingKind> = ({ hoisted: NodePath<FunctionDeclaration | ClassDeclaration>; local: NodePath<FunctionExpression | ClassExpression>; module: NodePath<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>; let: NodePath<VariableDeclarator> | NodePath<CatchClause>; param: NodePath<Pattern>; unknown: NodePath<FunctionDeclaration | ClassDeclaration>; } & { [_ in 'var' | 'const']: NodePath<VariableDeclarator>; })[T]; export declare class Binding<T extends BindingKind = BindingKind> extends BaseBinding { readonly kind: BindingKind; readonly name: string; readonly scope: Scope; readonly identifierPath: NodePath<Identifier>; readonly path: BindingPathT<T>; constructor(data: { kind: Binding['kind']; name: string; scope: Scope; identifierPath: Binding['identifierPath']; path: BindingPathT<T>; }); get constant(): boolean; } export declare class GlobalBinding extends BaseBinding { readonly kind = "global"; readonly constant = false; readonly name: string; constructor(data: { name: string; }); } export {};