fix: re-export FocusableElement, HoverEvent and KeyboardEvent types from react-aria-components - #10366
Open
sobol-sudo wants to merge 1 commit into
Open
fix: re-export FocusableElement, HoverEvent and KeyboardEvent types from react-aria-components#10366sobol-sudo wants to merge 1 commit into
sobol-sudo wants to merge 1 commit into
Conversation
…rom react-aria-components
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.
Closes #10166.
react-aria-componentsre-exports a curated subset of@react-types/shared, but three types that show up structurally in the publicButtonPropsaren't in that list:FocusableElement,HoverEventandKeyboardEvent. Since@react-types/sharedis only a transitive dependency for consumers, TypeScript can't write a portable import for those names when it emits declarations, so a project usingcomposite+declarationthat wrapsButtonor exports a type inferred fromButtonPropsfails with TS2883.The chain is
ButtonProps→AriaButtonProps→PressEvents/FocusableProps:onClickis typedMouseEvent<FocusableElement>,onKeyDown/onKeyUptake the sharedKeyboardEventalias, andHoverEventsbrings inHoverEvent. TheOmit<>onButtonPropsdoesn't strip any of them.This adds the three names to the existing
@react-types/sharedre-export block, and toexports/Button.ts, which is a published subpath that already re-exportsPressEventfrom the same module and hits the same error. It deliberately doesn't blanket re-export everything from@react-types/shared, per @LFDanLu's note on the issue. Same shape as #9955.I also added four assertions to the existing
test/types.tsxso these stay nameable from the package root. Three of them fail onmainwith TS2694; the fourth isPressEvent, which already works and is there as a control so the whole event-type group is covered rather than just the new names.react-ariahas the same gap — it exportsHoverEventandKeyboardEventsbut notKeyboardEventorFocusableElement. Happy to do that as a follow-up if you want it.