Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1cfad5f3-549a-4cdb-b105-a8e1fc618670
Contributor
|
Contributor
There was a problem hiding this comment.
🟢 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
|
Integration test results from github/github-ui PR: |
This branch was successfully deployed
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.
This PR fixes component-specific props becoming
anyinside generic polymorphic components, such asAnnounce'sdelayMs. It preserves existing component APIs, including customascomponents, refs, and event types.Changelog
New
Changed
asare handled.Removed
Rollout strategy
Patch release. No consumer or runtime changes are needed.
Testing & Reviewing