downshift icon indicating copy to clipboard operation
downshift copied to clipboard

Fix typeing: Allow for null value in combobox selectItem type.

Open bobjohnbob opened this issue 4 years ago • 1 comments

What: Update the types file to allow the item passed into selectItem (returned from useCombobox) to be null.

Why: Without this, you can't selectItem(null) using typescript. This is done in the useMultiselect example in the docs, but currently not allowed by typescript types. (See the example from the docs here: https://codesandbox.io/s/github/kentcdodds/downshift-examples?file=/src/hooks/useMultipleSelection/combobox.js:1466-1495 )

How: I added | null to the item parameter's type.

Checklist:

  • [x] Documentation
  • [x] Tests n/a
  • [x] TypeScript Types
  • [x] Flow Types n/a
  • [x] Ready to be merged

I tried to update flow types as well, but couldn't find the relevant flow types. I'm not too familiar with flow, so it might just be a case of I me not knowing what I'm doing.

I tried to run tests before opening the PR, but npm install is currently failing with react version mismatches in dependencies and I really doubt this will break any tests. If you have a way to get tests working, I'll be happy to run them.

Error from npm install:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   dev react@"^17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from [email protected]
npm ERR! node_modules/docz
npm ERR!   dev docz@"^2.3.1" from the root project
npm ERR! 

bobjohnbob avatar Oct 27 '21 23:10 bobjohnbob

I came here to open this same PR before finding this - Could someone review & merge this please?

drewbrend avatar Jan 25 '22 14:01 drewbrend

This is done already. 🎉 Closing

silviuaavram avatar Dec 17 '22 15:12 silviuaavram