-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Types are generally incompatible with ReadonlyArray #7656
Comments
I can contribute PR's to update where and as it affects me but I'd like a response as to whether you would accept those first. |
Thanks for the issue, and apologies for the delay! Brought this up with the team it looks like these should probably be |
Thanks, it fixes it, I can raise a PR |
That would be great! |
lukeapage
added a commit
to lukeapage/react-spectrum
that referenced
this issue
Feb 7, 2025
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Provide a general summary of the issue here
Props that take array's generally use the mutable form e.g. here the columns
https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/src/Table.tsx#L529
🤔 Expected Behavior?
They instead be typed to take ReadonlyArray where the array is not mutated - that then allows the consumer to pass a mutable or a readonly array.
😯 Current Behavior
An error trying to assign a readonly array to a prop that takes a mutable array
💁 Possible Solution
Updating alot of
T[]
->ReadonlyArray<T>
🔦 Context
We use readonly arrays frequently to make sure no-one is mutating a value they shouldn't and causing a unintended side effect. The current design means we would need to add a typescript expect error to use readonly arrays or a cast.
🖥️ Steps to Reproduce
N/A
Version
N/A
What browsers are you seeing the problem on?
Other
If other, please specify.
No response
What operating system are you using?
N/A
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: