Provide a general summary of the issue here
react-aria-components exposes FocusableElement, HoverEvent, and KeyboardEvent (from @react-types/shared) as part of the structural type of ButtonProps, but does not re-export them from its own package. In TypeScript monorepos using project references (composite: true, declaration: true), any file that re-exports or infers a type involving ButtonProps produces TS2883 errors because TypeScript must emit declaration files that name those types, yet has no portable way to import them — @react-types/shared is a transitive dependency, not a direct one, and TypeScript cannot write a stable import for it in emitted .d.ts files.
🤔 Expected Behavior?
react-aria-components should re-export all types from @react-types/shared that appear in its public API surface (e.g. as part of ButtonProps). Consumers using composite: true + declaration: true should be able to build without TS2883 errors, without needing to add @react-types/shared as a direct dependency.
😯 Current Behavior
In any TypeScript monorepo with project references, files that expose types derived from ButtonProps (e.g. a wrapper component, or Storybook CSF stories with inferred types) emit:
error TS2883: The inferred type of 'Button' cannot be named without a reference to
'FocusableElement' from '.../@react-types/shared'. This is likely not portable.
A type annotation is necessary.
error TS2883: The inferred type of 'Button' cannot be named without a reference to
'HoverEvent' from '.../@react-types/shared'. This is likely not portable.
A type annotation is necessary.
error TS2883: The inferred type of 'Button' cannot be named without a reference to
'KeyboardEvent' from '.../@react-types/shared'. This is likely not portable.
A type annotation is necessary.
The three types surface because:
FocusableElement — PressEvents.onClick?: (e: MouseEvent<FocusableElement>) => void (via AriaButtonProps → ButtonProps → PressEvents)
HoverEvent — HoverEvents.onHoverStart/End?: (e: HoverEvent) => void (direct extends on react-aria-components ButtonProps)
KeyboardEvent (@react-types/shared, not DOM) — KeyboardEvents.onKeyDown/Up?: (e: KeyboardEvent) => void (via AriaButtonProps → ButtonProps → FocusableProps → KeyboardEvents)
None of these types are re-exported from react-aria-components' root, so TypeScript cannot name them through a direct dependency.
💁 Possible Solution
Add the three types to the existing @react-types/shared re-export line in dist/types/exports/index.d.ts:
-export type { RangeValue, ValidationResult, RouterConfig } from '@react-types/shared';
+export type { RangeValue, ValidationResult, RouterConfig, FocusableElement, HoverEvent, KeyboardEvent } from '@react-types/shared';
This is consistent with the existing pattern of re-exporting @react-types/shared types that are part of the public API. We confirmed locally (via a pnpm patch) that this one-line change resolves all TS2883 errors related to ButtonProps.
There may be other TS2883 errors we didn't run into related to other types that also need to be re-exported. The better solution may be to simply re-export all types from @react-types/shared.
🔦 Context
This affects any TypeScript monorepo using project references where a package wraps or re-exports React Aria Components and emits declaration files. It is not specific to any particular package manager or symlink resolution strategy — the issue is that TypeScript needs a stable, direct-dependency import path for every type that appears in emitted .d.ts files, and these three types currently have none through react-aria-components.
🖥️ Steps to Reproduce
- Create a TypeScript monorepo with project references (two packages:
pkg-a and pkg-b)
- Add
react-aria-components as a direct dependency of pkg-a
- In
pkg-a/tsconfig.json: set "composite": true, "declaration": true
- In
pkg-a, create a component that wraps Button from react-aria-components and exports its props type (or any file that infers and exports a type involving ButtonProps)
- Run
tsc -b from the repo root
Expected: build succeeds
Actual: TS2883 on every exported symbol whose inferred type involves FocusableElement, HoverEvent, or KeyboardEvent from @react-types/shared
Version
react-aria-components@1.18.0, @react-types/shared@3.35.0
What browsers are you seeing the problem on?
N/A — TypeScript tooling / build issue, not a browser runtime issue.
What operating system are you using?
macOS (confirmed), likely reproducible on all platforms.
Provide a general summary of the issue here
react-aria-componentsexposesFocusableElement,HoverEvent, andKeyboardEvent(from@react-types/shared) as part of the structural type ofButtonProps, but does not re-export them from its own package. In TypeScript monorepos using project references (composite: true,declaration: true), any file that re-exports or infers a type involvingButtonPropsproduces TS2883 errors because TypeScript must emit declaration files that name those types, yet has no portable way to import them —@react-types/sharedis a transitive dependency, not a direct one, and TypeScript cannot write a stable import for it in emitted.d.tsfiles.🤔 Expected Behavior?
react-aria-componentsshould re-export all types from@react-types/sharedthat appear in its public API surface (e.g. as part ofButtonProps). Consumers usingcomposite: true+declaration: trueshould be able to build without TS2883 errors, without needing to add@react-types/sharedas a direct dependency.😯 Current Behavior
In any TypeScript monorepo with project references, files that expose types derived from
ButtonProps(e.g. a wrapper component, or Storybook CSF stories with inferred types) emit:The three types surface because:
FocusableElement—PressEvents.onClick?: (e: MouseEvent<FocusableElement>) => void(viaAriaButtonProps→ButtonProps→PressEvents)HoverEvent—HoverEvents.onHoverStart/End?: (e: HoverEvent) => void(direct extends onreact-aria-componentsButtonProps)KeyboardEvent(@react-types/shared, not DOM) —KeyboardEvents.onKeyDown/Up?: (e: KeyboardEvent) => void(viaAriaButtonProps→ButtonProps→FocusableProps→KeyboardEvents)None of these types are re-exported from
react-aria-components' root, so TypeScript cannot name them through a direct dependency.💁 Possible Solution
Add the three types to the existing
@react-types/sharedre-export line indist/types/exports/index.d.ts:This is consistent with the existing pattern of re-exporting
@react-types/sharedtypes that are part of the public API. We confirmed locally (via apnpm patch) that this one-line change resolves all TS2883 errors related toButtonProps.There may be other TS2883 errors we didn't run into related to other types that also need to be re-exported. The better solution may be to simply re-export all types from
@react-types/shared.🔦 Context
This affects any TypeScript monorepo using project references where a package wraps or re-exports React Aria Components and emits declaration files. It is not specific to any particular package manager or symlink resolution strategy — the issue is that TypeScript needs a stable, direct-dependency import path for every type that appears in emitted
.d.tsfiles, and these three types currently have none throughreact-aria-components.🖥️ Steps to Reproduce
pkg-aandpkg-b)react-aria-componentsas a direct dependency ofpkg-apkg-a/tsconfig.json: set"composite": true, "declaration": truepkg-a, create a component that wrapsButtonfromreact-aria-componentsand exports its props type (or any file that infers and exports a type involvingButtonProps)tsc -bfrom the repo rootExpected: build succeeds
Actual: TS2883 on every exported symbol whose inferred type involves
FocusableElement,HoverEvent, orKeyboardEventfrom@react-types/sharedVersion
react-aria-components@1.18.0,@react-types/shared@3.35.0What browsers are you seeing the problem on?
N/A — TypeScript tooling / build issue, not a browser runtime issue.
What operating system are you using?
macOS (confirmed), likely reproducible on all platforms.