Skip to content

fix(resolution): a store-action binding is not a local shadow - #1763

Closed
bompus wants to merge 1 commit into
colbymchenry:mainfrom
bompus:fix/store-binding-not-a-shadow
Closed

fix(resolution): a store-action binding is not a local shadow#1763
bompus wants to merge 1 commit into
colbymchenry:mainfrom
bompus:fix/store-binding-not-a-shadow

Conversation

@bompus

@bompus bompus commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #1762.

#1759 made isLocallyBoundJsName treat a Zustand-style store binding as a local rebinding, so bare calls to store actions stopped resolving. main at cd4e65b currently fails its own __tests__/object-literal-methods.test.ts with expected [] to include 'loginFlow', plus two tests in __tests__/ui-steps-api.test.ts.

The change

isLocallyBoundJsName already carves out require(...) / import(...) on the right-hand side, because an imported name is a node elsewhere rather than a shadow. This extends that same carve-out to store bindings, which are the same situation — the action is a node in the store file, so the bare call that follows means it:

const { fetchUser } = useStore.getState();   // accessor shapes matchStoreAccessorChain already knows
const { fetchUser } = get();                 // inside the factory
const setZipUri = useStore((s) => s.setZipUri);  // selector reading the same name

A selector returning a different name is a genuine rebinding and still shadows.

The selector pattern is deliberately narrow: one named parameter, and a plain member read of the same name ((?!\s*\()). const now = options.now || (() => Date.now()) matches neither clause — no parameter, and .now() is a call — so it stays the local binding this predicate exists to find. bare-call-no-method covers that case and stays green.

Verification

Full suite, same machine and same build, pristine cd4e65b vs this branch:

pristine this branch
Test files 13 failed 7 failed
Unique failing tests 29 24

object-literal-methods and both ui-steps-api tests go green, and no test that passed before fails after. The remaining 24 are pre-existing on this machine (Windows, native kernel not built) and identical across both runs.

…chenry#1762)

isLocallyBoundJsName carves out require()/import() on the right-hand side,
because an imported name is a node elsewhere rather than a shadow. A store
binding is the same situation: the action is a node in the store file, so the
bare call that follows means it.

Covers the two accessor shapes matchStoreAccessorChain already recognises
(useStore.getState(), get() inside the factory) and a selector that reads the
same name off the state. A selector returning a different name is a genuine
rebinding and still shadows.

Fixes __tests__/object-literal-methods.test.ts and two in
__tests__/ui-steps-api.test.ts, which fail on main at cd4e65b.
@bompus

bompus commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Duplicate of #1760, which fixes the same regression. Closing; verification data moved to #1760.

@bompus bompus closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression (#1759): store-action bindings treated as local shadows; main fails its own object-literal-methods test

1 participant