react-spectrum
react-spectrum copied to clipboard
[react-stately][useControlledState] Allow undefined params
Closes #1859
✅ Pull Request Checklist:
- [x] Included link to corresponding React Spectrum GitHub Issue.
- [ ] ~~Added/updated unit tests and storybook for this change (for new code or code which already has tests).~~ (No existing way of checking types found, so I couldn't test this.)
- [x] Filled out test instructions.
- [x] Updated documentation (if it already exists for this component).
- [x] Looked at the Accessibility Practices for this feature - Aria Practices
📝 Test Instructions:
Try doing useControlledState(undefined, undefined, undefined)
in typescript with strictNullChecks
compiler option turned on. There should not be any TypeScript errors.
🧢 Your Project:
https://github.com/ChocolateLoverRaj/color-picker
Signed Adobe CLA
Not sure about this - see my question https://github.com/adobe/react-spectrum/issues/1890#issuecomment-841550833
Not sure about this - see my question #1890 (comment)
@dannify This pull request fixes #1859, which fixes strictNullChecks
errors on packages using @react-stately/utils
. This pull request doesn't require the strictNullChecks
compiler to be turned on for this package, which is what #1890 is about. This PR only adds 3 | undefined
s to the code.
Yes but as you said, it only solves it for one package and would be introducing the method for solving this problem across all of our packages (even if we did it incrementally) so I want to look at alternative ways to solve the problem as a whole.
@danify while it may be hard to solve this problem for all packages, for now you are making it inconvenient for people who do use strictNullChecks
.
Correct me if I'm wrong but without this fix you can't really use this utility as intended in a TS codebase with strict
or structNullChecks
set to true
? Was really looking forward to a clever drop-in solution. Fixing the types for this utility so that they are strictly correct doesn't mean any of the other packages that depend on this utility also need to opt in to strict mode. Just that projects that do opt-in can use the utility without workarounds.
please merge this
I turned on our strict type checking for this file, I believe this PR to be wrong. I've opened a PR to address it here https://github.com/adobe/react-spectrum/pull/3926