Skip to content

fix(react): preserve polymorphic component prop inference - #8638

Open
joshblack wants to merge 1 commit into
mainfrom
fix-components-preserve-api
Open

joshblack wants to merge 1 commit into
mainfrom
fix-components-preserve-api

Conversation

@joshblack

Copy link
Copy Markdown
Member

This PR fixes component-specific props becoming any inside generic polymorphic components, such as Announce's delayMs. It preserves existing component APIs, including custom as components, refs, and event types.

Changelog

New

Changed

  • Fix inference for component-specific props without changing how overlapping props or as are handled.
  • Update ActionList's internal typing to work with the corrected inference.

Removed

Rollout strategy

Patch release. No consumer or runtime changes are needed.

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • None

Testing & Reviewing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1cfad5f3-549a-4cdb-b105-a8e1fc618670
Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:01
@joshblack
joshblack requested a review from a team as a code owner October 29, 2026 17:01
@joshblack
joshblack requested a review from liuliu-dev October 29, 2026 17:01
@github-actions github-actions Bot added the staff Author is a staff member label Oct 29, 2026
@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the component-specific prop inference fix.

No open issues 🎉

What changed in this PR

This PR corrects TypeScript inference for component-specific props in Primer React’s shared polymorphic utility, while preserving existing as, ref, event, and overlapping-prop behavior.

Changes:

  • Separates component-specific props from element props in PolymorphicProps.
  • Adjusts ActionList’s internal typing and removes an obsolete TypeScript error suppression.
  • Adds type regression tests and a patch changeset for @primer/react.
File Description
packages/​react/​src/​utils/​modern-polymorphic.types.test.tsx Tests own-prop inference, unions, overlaps, and as handling.
packages/​react/​src/​utils/​modern-polymorphic.ts Keeps own props separate to preserve generic inference.
packages/​react/​src/​Link/​__tests__/​Link.types.test.tsx Tests polymorphic elements, custom components, refs, and events.
packages/​react/​src/​ActionList/​List.tsx Removes an obsolete ref-related error suppression comment.
packages/​react/​src/​ActionList/​LinkItem.tsx Explicitly types the internal Item as li.
packages/​react/​src/​ActionList/​ActionList.types.test.tsx Adds coverage for polymorphic LinkItem and List props.
.changeset/​polymorphic-prop-inference.md Records the inference fix as a patch release.

Review effort: Balanced

@primer-integration

primer-integration Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed  Changes   Passed
Passed  CI   Passed
Waiting  VRT   Waiting
Passed  Projects   Passed

This branch was successfully deployed

2 active deployments
storybook-preview-8638 — c275dd8d Deployed Oct 29, 2026 by github-actions[bot]
github-pages — c275dd8d Deployed Oct 29, 2026 by joshblack via deploy-preview #33966
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants