Repository navigation
Conversation
Clone the previous Set before deleting or toggling values so NaN follows Set membership semantics while previous state and reset remain unchanged. Generated-by: OpenAI Codex
The three added cases fail before the fix. The useSet, useMap and useList suites pass after it (56 tests); useSet has 100% statement, branch, function and line coverage. Generated-by: OpenAI Codex
This branch has not been deployed
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.
Description
useSet(new Set([NaN, 1]))reports thatNaNis present, but bothremove(NaN)andtoggle(NaN)leave it in the set. Removal currently filters with strict inequality, for whichNaN !== NaN.Clone the previous set and use native
Set.deleteso removal follows the same equality semantics as membership. Toggling uses the same approach. Previous state snapshots, the caller's initial set, reset behavior, and stable action references are preserved.Three regression cases cover NaN removal, toggling on/off, and immutable state/reset. All three fail against the original implementation.
Related: #2669 and #2687 propose broader ref-based rewrites. This PR keeps the existing immutable state implementation and addresses the NaN correctness issue only.
Type of change
Validation
yarn test: 76 suites, 495 tests passed.yarn lint: passed with 0 errors and 97 warnings.yarn lint:types: passed.yarn build: CommonJS and ES module builds passed.git diff --check: passed.Checklist
AI assistance: OpenAI Codex prepared the implementation and tests, ran the checks, and drafted this PR.
Replaces #2729 after renaming the source branch; the commits are unchanged.