Repository navigation
fix(resolution): recognize later declarators and destructuring defaults as local bindings (#3293) - #3294
fix(resolution): recognize later declarators and destructuring defaults as local bindings (#3293)#3294mohitdixit02 wants to merge 2 commits into
Conversation
…ts as local bindings (colbymchenry#3293)
aa17cb5 to
7ec8922
Compare
|
Thanks for picking this up so quickly, @mohitdixit02. The five shapes from #3293 all link to I merged head 1. Indexing can stall on long declaration lists. In the new prefix pattern for earlier declarators, the whitespace before a
Matching the whitespace on only one side of the comma, or making each declarator atomic, should remove the blow-up. 2. Destructuring in a 3. A comma that doesn't separate declarators now reads as one. Each of these makes
4. With 5. Smaller ones. I only checked these against the regex directly, not end to end:
None of these would fail the new test, because it covers only the positive shapes. A few negative cases, a Checked and fine on this branch: renamed and nested destructuring ( Edit (2026-11-16): Thanks for the quick update. I re-ran everything on
On a broader check of about 40,000 call edges from real packages (svelte, vitest, rollup, chai, acorn and others), only 4 edges changed: 3 were correct removals, and the 4th exposed a mismatch that already exists on |
|
Thanks a lot for the detailed review and test cases, @inth3shadows! I've pushed an update (
I also added tests covering each of these positive and negative shapes in |
When a local variable shadows an outer variable typed with a package type (such as a module-scoped
let root: Root | nullfromreact-dom/client), calls made on that local receiver were incorrectly dropped if the local was declared in a comma-separated declaration list (let n = 0, ob = new Chart()) or extracted via destructuring with defaults (const { ob = new Chart() } = opt). BecauselocalBindingPatterns.declandjsDeclarationReadingexpected the target identifier to immediately followconst|let|var\s+, and destructuring patterns rejected any=, CodeGraph failed to identify the nearer local binding site and fell back to the outer package-typed symbol, refusing to resolve calls against matching project methods.This change introduces
PREV_VAR_DECLto account for preceding declarators in variable lists, allows destructuring patterns containing default initializers (=), and updatesjsBindingSitesto inspect both plain and destructured initializer branches. Nearer local bindings in these shapes are now accurately recognized, allowing local calls to resolve cleanly against project methods rather than being suppressed by an outer package type.Fixes #3293
Co-authored-by: @inth3shadows