react-accessible-dropdown-menu-hook icon indicating copy to clipboard operation
react-accessible-dropdown-menu-hook copied to clipboard

Export type definitions for button and item props

Open msakrejda opened this issue 3 years ago • 3 comments

Hi,

Thanks for making this! I started using it in my app but wanted to wrap it to keep a consistent look and feel for menus in my app. However, I wanted to keep the interface flexible, so I'd like to just re-export parts of the underlying types in my wrapper component's props. I can't do that right now because those are not exported.

Thoughts on exporting the button and item prop types like this?

msakrejda avatar Feb 21 '22 21:02 msakrejda

Hi @uhoh-itsmaciek , thanks for using our package and being open to making contributions. For this contribution, it seems like your use-case can be covered by the ReturnType utility type that Typescript provides. Something like ReturnType<typeof useDropdownMenu>, I think that would probably satisfy any case where someone needed access to the return value type of the hook, what do you think?

corymharper avatar Feb 22 '22 16:02 corymharper

Hi @uhoh-itsmaciek , thanks for using our package and being open to making contributions. For this contribution, it seems like your use-case can be covered by the ReturnType utility type that Typescript provides. Something like ReturnType<typeof useDropdownMenu>, I think that would probably satisfy any case where someone needed access to the return value type of the hook, what do you think?

After some review, after the introduction of generics which we plan to expand in the future, the solution I provided here is actually very obtuse.

corymharper avatar Feb 22 '22 17:02 corymharper

Oh good point, I could work with ReturnType, yeah. I think it'd still be nice to have something more straightforward (especially if as you say this will get more complex with generics), but I think it's okay for now.

msakrejda avatar Feb 23 '22 05:02 msakrejda

Codecov Report

Base: 98.07% // Head: 98.07% // No change to project coverage :thumbsup:

Coverage data is based on head (47095e1) compared to base (a4e57e8). Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #296   +/-   ##
=======================================
  Coverage   98.07%   98.07%           
=======================================
  Files           1        1           
  Lines         104      104           
  Branches       33       33           
=======================================
  Hits          102      102           
  Misses          2        2           
Impacted Files Coverage Δ
src/use-dropdown-menu.ts 98.07% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Feb 23 '23 19:02 codecov[bot]