Skip to content

fix(react-utils/createPolymorph): allow components to set displayName - #814

Merged
maeertin merged 1 commit into
mainfrom
feat/react-utils-createPolymorph-displayName
Aug 21, 2026
Merged

fix(react-utils/createPolymorph): allow components to set displayName#814
maeertin merged 1 commit into
mainfrom
feat/react-utils-createPolymorph-displayName

Conversation

@maeertin

@maeertin maeertin commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

createPolymorph returns the original render function at runtime, so React components created by it can already have displayName assigned. Its TypeScript return type only described the callable signature, however, valid assignments such as Button.displayName = 'Button' to fail type checking. This change exposes the optional property in the public type and adds regression coverage.

@maeertin
maeertin requested review from Dashice and adamsoderstrom and a lite review from Copilot August 14, 2026 07:29
@maeertin maeertin self-assigned this Aug 14, 2026
@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c081ea1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@noaignite/react-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 14, 2026 9:13am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates @noaignite/react-utils’s createPolymorph typing so polymorphic components can set a React-style displayName property, improving DX for debugging and DevTools labeling.

Changes:

  • Extend PolymorphicExoticComponent’s type to include an optional displayName?: string static.
  • Add a unit test ensuring displayName can be assigned and read on a component returned by createPolymorph.
  • Add a patch changeset for @noaignite/react-utils.

Changed packages/apps: @noaignite/react-utils
Changeset: Included (patch)
Docs impact: None apparent (type-only enhancement + test)
Recommended verification commands:

  • pnpm -F @noaignite/react-utils test:unit
  • pnpm -F @noaignite/react-utils test:types

Risk level: Low

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/react-utils/src/createPolymorph.ts Adds displayName?: string to the polymorphic component return type so consumers can set it without type errors.
packages/react-utils/src/createPolymorph.test.tsx Adds a test verifying displayName can be assigned/read on a createPolymorph result.
.changeset/clear-geese-name.md Declares a patch release note for the @noaignite/react-utils change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Dashice Dashice 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.

Approved with one optional comment.

Comment thread packages/react-utils/src/createPolymorph.ts
@maeertin
maeertin force-pushed the feat/react-utils-createPolymorph-displayName branch from dfce5cb to c081ea1 Compare August 14, 2026 09:12
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #814      +/-   ##
==========================================
+ Coverage   70.62%   70.64%   +0.02%     
==========================================
  Files          67       67              
  Lines        1062     1063       +1     
  Branches      268      269       +1     
==========================================
+ Hits          750      751       +1     
  Misses        248      248              
  Partials       64       64              
Files with missing lines Coverage Δ
packages/react-utils/src/createPolymorph.ts 80.00% <100.00%> (+5.00%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maeertin
maeertin merged commit 741905e into main Aug 21, 2026
5 checks passed
@maeertin
maeertin deleted the feat/react-utils-createPolymorph-displayName branch August 21, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants