Skip to content

fix: declare optional React type peers for published packages - #10953

Open
Sophran-fbj wants to merge 1 commit into
adobe:mainfrom
Sophran-fbj:fix/react-types-optional-peers
Open

Sophran-fbj wants to merge 1 commit into
adobe:mainfrom
Sophran-fbj:fix/react-types-optional-peers

Conversation

@Sophran-fbj

Copy link
Copy Markdown

Closes #10940

Summary

In pnpm's global virtual store, the published declarations can resolve react to its untyped JavaScript entry even when the application has installed @types/react. This loses contextual typing for callbacks such as Button.onKeyDown.

Declare @types/react as an optional peer in react-aria-components, react-aria, react-stately, and @react-types/shared. The * range lets consumers supply their existing React types, while the optional flag keeps JavaScript-only installs working without them. Update the workspace lockfile accordingly.

Also exclude optional peers from the workspace constraint that propagates required peers. Otherwise, these declarations cause the constraint to require many dependent workspaces to declare the type peer as a required dependency. Required-peer propagation is unchanged. Manifest key ordering was normalized by the repository formatter.

Prepared with AI assistance (Codex), including implementation, local validation, and this description.

📝 Test Instructions

  • Consumer reproduction: pnpm 12.18.0, virtualStoreType: global, addMissingPeerTypes: false, autoInstallPeers: false, TypeScript 5.9.3, React/types 19.3.0. With the released versions listed in the issue, a Button keyboard callback has an implicitly-any parameter (TS7006), and an @ts-expect-error for an invalid event property is unused (TS2578).
  • Repacked those same four released packages with the peer metadata from this branch, retaining their released JS/declarations. Installed the tarballs for direct and transitive dependencies in the same isolated layout. The identical consumer typecheck passes, including the invalid-property negative assertion. These are metadata-only packaging checks, not a build of the branch.
  • A JavaScript consumer without @types/react installs the patched tarballs without adding React types and can import Button.
  • yarn lint passes, including formatting, typechecking, package lint, and constraints. yarn install --immutable --mode=skip-build passes. Local constraint smoke checks confirm optional peers are skipped and non-optional peers still propagate.
  • Full yarn test --maxWorkers=2 --silent: 380 suites passed, 4 failed; 7,909 tests passed, 16 failed, 16 skipped. Failures are in NumberField, NumberParser, LocalesResolver, and codemod CLI tests on this Windows run (including empty locale test data and Windows path differences). Those implementations/tests are unchanged by this PR.
  • Full yarn test:ssr --silent: 58 suites passed, 2 timed out. Both failed suites pass when rerun with --testTimeout=120000 (5 tests).
  • yarn build could not run because make is unavailable on this Windows host. Browser/VRT coverage is not applicable to the dependency metadata change; no Chromatic runs were started.

Release impact

  • Only changes docs, tests, CI, or development tools. Nothing shipped to users changes.
  • Fixes a bug or improves existing code without changing how apps use it.
  • Adds a feature or API while keeping existing usage working.
  • May break existing usage or require changes in apps that use this code.

✅ PR Checklist

  • I followed the contributing guide.
  • I tested this change locally and included the results in Test Instructions, or explained why testing does not apply.
  • I understand and can explain every change in this PR. If I used AI assistance, I followed the AI contribution guidance.

The final ownership/understanding checkbox is left for the human author to confirm.

🧢 Your Project

Personal open-source contribution.

@github-actions github-actions Bot added the RAC label Nov 10, 2026
@Sophran-fbj Sophran-fbj reopened this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Declare @types/react as an optional peer dependency

1 participant