Repository navigation
fix(types): accept readonly items in selection hooks - #1702
Open
minwookshin wants to merge 1 commit into
Open
minwookshin wants to merge 1 commit into
minwookshin wants to merge 1 commit into
Conversation
Allow readonly arrays and tuples in select, combobox and multiple-selection inputs. Preserve readonly array ownership in multiple-selection state and callbacks, and cover frozen inputs and inferred item types. Closes downshift-js#1030 BREAKING CHANGE: useMultipleSelection selectedItems state and callback arrays are readonly. Callers requiring mutable arrays must copy them or accept readonly arrays.
Author
|
Could you approve the pending validate workflow? Local results and the failures reproduced on the base branch are noted above. Thanks! |
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.
Pull Request
What
Accept readonly arrays and
as consttuples inuseSelect,useComboboxanduseMultipleSelection.Closes #1030.
Why
These hooks read the supplied arrays without mutating them, but the mutable-only declarations reject readonly inputs and lose tuple item inference.
How
Widen the array parameters in the hook declarations and their read-only helpers.
useMultipleSelectionalso exposes readonly state and callback arrays, since these can be the original caller-supplied arrays. There are no runtime changes.Type compatibility: callers that require mutable
useMultipleSelection.selectedItemsor callback arrays need to accept readonly arrays or make a copy. Mutable inputs remain supported. The multiple-select example's filtering helper is updated accordingly.Changes
test:ts; the readonly calls fail type checking before the change.Aquabut receivesBlack; it also fails on unmodified1bb8b75(which additionally failed the uncompiled variant).Existing tooling limitations were checked against that same base: the default ESLint parser exhausts its heap, and
kcd-scriptsinvokes TypeScript 4.9 for declarations despite the project's 5.9 dependency. With the project's current parser, full-repository lint has the same 73 errors and 19 warnings on both versions, with no added diagnostics. The pre-commit hook also rejects the existingbundlermodule resolution; it was skipped after the changed-file checks passed with the project parser. These unrelated tooling issues are unchanged.Checklist
Leaving the final item unchecked pending review of the type compatibility change and the baseline validation failures above.