fix(resolution): a store-action binding is not a local shadow - #1763
Closed
bompus wants to merge 1 commit into
Closed
fix(resolution): a store-action binding is not a local shadow#1763bompus wants to merge 1 commit into
bompus wants to merge 1 commit into
Conversation
…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.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1762.
#1759madeisLocallyBoundJsNametreat a Zustand-style store binding as a local rebinding, so bare calls to store actions stopped resolving.mainatcd4e65bcurrently fails its own__tests__/object-literal-methods.test.tswithexpected [] to include 'loginFlow', plus two tests in__tests__/ui-steps-api.test.ts.The change
isLocallyBoundJsNamealready carves outrequire(...)/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: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-methodcovers that case and stays green.Verification
Full suite, same machine and same build, pristine
cd4e65bvs this branch:object-literal-methodsand bothui-steps-apitests 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.