UNPKG

claude-flow

Version:

Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration

29 lines 1.51 kB
/** * Scope-aware reassignment analysis for the `var-to-const` codemod (ADR-143). * * The naive version marks a `var` as reassigned if its name is assigned to * *anywhere* in the file. That is correct but over-conservative: a `var x` in * one function is forced to `let` just because an unrelated function also has * an `x = …`. This module resolves each assignment to the binding it actually * mutates (function-scope hoisting semantics), so a `var` becomes `const` * unless *its own* binding is reassigned. * * Soundness: resolution only ever attributes a reassignment to a scope that * actually hoists the name (i.e. genuinely declares that binding). It therefore * never marks a truly-reassigned binding as un-reassigned — so a `var` is only * promoted to `const` when it is provably never reassigned. Block-scoped * shadowing (let/const) is ignored for resolution, which can only make us *more* * conservative (fall back to `let`), never wrong. * * @module ruvector/codemods/scope-analysis */ import ts from 'typescript'; export interface ReassignmentResolver { /** True if the `var` binding declared by `declarationList` (for `name`) is reassigned within its scope. */ isReassigned(name: string, declarationList: ts.VariableDeclarationList): boolean; } /** * Build a scope-aware resolver: which `var` bindings are actually reassigned. */ export declare function buildReassignmentResolver(sf: ts.SourceFile): ReassignmentResolver; //# sourceMappingURL=scope-analysis.d.ts.map