Skip to content

Components: Fix polymorphism typings leaking as prop - #82704

Open
aduth wants to merge 7 commits into
trunkfrom
fix/components-polymorphic-boolean-inference
Open

aduth wants to merge 7 commits into
trunkfrom
fix/components-polymorphic-boolean-inference

Conversation

@aduth

@aduth aduth commented Sep 9, 2026

Copy link
Copy Markdown
Member

What?

Related (extracted from): #70064 (comment)

Updates component polymorphism typings in @wordpress/component's WordPressComponentProps to fix an issue where typings would wrongly surface as as an available prop.

Why?

Typings accuracy.

How?

The previous issue is a result of how boolean interpreted as a union of true | false in the check IsPolymorphic extends true produces a union type { as?: … } | {}, therefore presenting as as an available prop when it is in-fact not intended as one.

Testing Instructions

Type-check should pass: npm run typecheck

Documentation update should produce no local changes: npm run docs:build

Bonus points: Verify that you cannot add an as prop to an instance of Menu component.

Use of AI Tools

Used Cursor IDE + Auto model to research and implement, plus Claude Code + Opus 4.5 for an adversarial review. Changes reviewed manually by myself.

@aduth aduth added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Package] Components /packages/components labels Sep 9, 2026
@aduth
aduth requested a review from a team as a code owner September 9, 2026 20:33
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

🤖 PR meta 🤖

📦 Bundle size

Size Change: 0 B

Total Size: 8.06 MB

35cd79f Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 0e76ca7c8cca4ca9873ec2d1ad93459ccf1430ee trunk % Change
timeToFirstByte 49.8 ms +2.11% -3.01% 49.6 ms +3.43% -2.52% 0.4%
largestContentfulPaint 86 ms +6.98% -2.33% 86 ms +6.98% -6.98% 0%
lcpMinusTtfb 35.9 ms +14.35% -7.66% 33.15 ms +25.19% -3.62% 8.3%
wpBeforeTemplate 23.27 ms +4.68% -0.95% 23.49 ms +3.92% -2.21% -0.94%
wpTemplate 22.64 ms +2.47% -5.61% 22.24 ms +4.54% -3.87% 1.8%
wpTotal 46.2 ms +2.21% -3.07% 46.02 ms +3.06% -3.13% 0.39%
wpMemoryUsage 7.53 MB +0% -0% 7.49 MB +0% -0% 0.45%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 0e76ca7c8cca4ca9873ec2d1ad93459ccf1430ee trunk % Change
timeToFirstByte 37.75 ms +3.18% -4.24% 32.35 ms +4.64% -1.39% 16.69%
largestContentfulPaint 88 ms +4.55% -0% 76 ms +2.63% -0% 15.79%
lcpMinusTtfb 51.65 ms +1.26% -3.58% 43.8 ms +1.03% -0.68% 17.92%
wpBeforeTemplate 20.56 ms +1.65% -1.75% 20.41 ms +2.01% -2.25% 0.73%
wpTemplate 13.09 ms +7.87% -2.29% 9.23 ms +4.88% -0.98% 41.82%
wpTotal 34.67 ms +3.26% -4.53% 29.55 ms +4.87% -1.56% 17.33%
wpMemoryUsage 5.52 MB +0% -0% 5.37 MB +0% -0% 2.65%
wpDbQueries 14 +0% -0% 10 +0% -0% 40%

media-processing

Metric 0e76ca7c8cca4ca9873ec2d1ad93459ccf1430ee trunk % Change
mediaProcessingJpeg 377.38 ms +2.67% -0.51% 380.03 ms +1.29% -0.54% -0.7%
mediaProcessingAvif 5604.87 ms +0.1% -0.16% 5603 ms +0.17% -0.13% 0.03%
mediaProcessingJpegToAvif 3840.63 ms +0.36% -0.15% 3828.78 ms +0.11% -0.18% 0.31%

media-upload

Metric 0e76ca7c8cca4ca9873ec2d1ad93459ccf1430ee trunk % Change
jpegUploadProcessing 1421.8 ms +37.08% -0.68% 1422.76 ms +0.43% -1.2% -0.07%
pngUploadProcessing 206.57 ms +5.5% -2.4% 211.41 ms +7.27% -6.27% -2.29%
largeJpegUploadProcessing 1415.6 ms +1.01% -0.43% 1412.31 ms +0.4% -0.47% 0.23%
multipleImageUploadProcessing 1520.26 ms +1.73% -0.68% 1533.27 ms +0.43% -3.18% -0.85%

post-editor

Metric 0e76ca7c8cca4ca9873ec2d1ad93459ccf1430ee trunk % Change
serverResponse 440.61 ms +1.38% -10.62% 385.1 ms +10.86% -1.47% 14.41%
firstPaint 229.16 ms +20.48% -4.19% 248.86 ms +10.66% -17.61% -7.92%
domContentLoaded 1261.79 ms +2.94% -1.83% 1258.96 ms +1.82% -1.06% 0.22%
loaded 1262.89 ms +2.96% -1.83% 1260.22 ms +1.82% -1.05% 0.21%
firstContentfulPaint 427.8 ms +2.87% -5.76% 422.56 ms +3.65% -2.56% 1.24%
firstBlock 3422.9 ms +0.99% -0.58% 3413.08 ms +1.15% -0.61% 0.29%
type 14.48 ms +14.64% -0.9% 14.87 ms +7.4% -1.41% -2.62%
typeWithoutInspector 14.61 ms +4.04% -4.79% 14.87 ms +1.88% -9.08% -1.75%
typeWithTopToolbar 18.28 ms +10.39% -4.05% 17.25 ms +6.09% -4.7% 5.97%
typeContainer 9.41 ms +11.58% -8.82% 9.13 ms +4.05% -6.68% 3.07%
focus 78.34 ms +4.66% -11.41% 72.69 ms +33.77% -6.07% 7.77%
firstFocus 175.99 ms +0% -0% 168.77 ms +0% -0% 4.28%
selectAll 536.76 ms +4.72% -0.25% 548.41 ms +0.28% -0.81% -2.12%
listViewOpen 68.77 ms +22.13% -9.02% 64.49 ms +13.26% -6.78% 6.64%
inserterOpen 23.41 ms +10.85% -7.43% 23.51 ms +8.76% -10.25% -0.43%
inserterHover 3.76 ms +12.23% -10.64% 4.05 ms +12.84% -10.86% -7.16%
inserterSearch 7.97 ms +4.14% -7.65% 8.59 ms +9.2% -4.77% -7.22%
loadPatterns 651.47 ms +3.22% -3.03% 639.73 ms +4.13% -2.38% 1.84%
wpTotal 429.41 ms +1.42% -10.74% 374.21 ms +11.1% -1.48% 14.75%
wpMemoryUsage 13.06 MB +0% -0% 13.03 MB +0% -0% 0.28%
wpDbQueries 54 +0% -0% 54 +0% -1.85% 0%

site-editor

Metric 0e76ca7c8cca4ca9873ec2d1ad93459ccf1430ee trunk % Change
serverResponse 520.3 ms +3.75% -5.7% 481.65 ms +13.35% -1.52% 8.02%
firstPaint 268.01 ms +9.82% -12.2% 246.18 ms +12.47% -9.93% 8.87%
domContentLoaded 1384.23 ms +1.26% -1.24% 1369.02 ms +1.92% -1.89% 1.11%
loaded 1385.47 ms +1.25% -1.26% 1370.25 ms +1.91% -1.9% 1.11%
firstContentfulPaint 440.42 ms +1.34% -0.68% 429.89 ms +1.71% -0.8% 2.45%
firstBlock 4475.38 ms +1.4% -0.4% 4435.55 ms +0.75% -0.49% 0.9%
type 14.15 ms +7.07% -6.36% 14.61 ms +6.37% -1.3% -3.15%
navigate 103.1 ms +4.66% -1.38% 104.75 ms +2% -11.06% -1.58%
loadPatterns 1626.05 ms +5.69% -12.13% 1450.53 ms +6.79% -12.09% 12.1%
loadPages 1100.81 ms +1.36% -1.58% 1071.64 ms +2.59% -0.35% 2.72%
wpTotal 510.7 ms +3.72% -5.91% 472.22 ms +13.53% -1.64% 8.15%
wpMemoryUsage 12.07 MB +0% -0% 12.04 MB +0% -0% 0.3%
wpDbQueries 43 +2.33% -0% 43 +2.33% -0% 0%

35cd79f Run

🏁 Flaky tests

Show the failures

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

refuses the drop and uploads nothing in /test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js, passed after 1 failed attempt.
Error: expect(received).toHaveLength(expected)

Expected length: 0
Received length: 2
Received array:  [{"_links": {"about": [{"href": "http://localhost:8889/wp-json/wp/v2/types/attachment"}], "author": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/users/1"}], "collection": [{"href": "http://localhost:8889/wp-json/wp/v2/media"}], "replies": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/comments?post=97"}], "self": [{"href": "http://localhost:8889/wp-json/wp/v2/media/97", "targetHints": {"allow": ["GET", "POST", "PUT", "PATCH", "DELETE"]}}]}, "alt_text": "", "author": 1, "caption": {"rendered": ""}, "class_list": ["post-97", "attachment", "type-attachment", "status-inherit", "hentry", "entry"], "comment_status": "open", "date": "2026-09-09T20:58:04", "date_gmt": "2026-09-09T20:58:04", "description": {"rendered": "<p class=\"attachment\"><a href='http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK-1.png'><img loading=\"lazy\" decoding=\"async\" width=\"10\" height=\"10\" src=\"http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK-1.png\" class=\"attachment-medium size-medium\" alt=\"\" style=\"width:100%;height:100%;max-width:10px;\" /></a></p>
"}, "featured_media": 0, "filename": "10x10_e2e_test_image_z9T8jK-1.png", "filesize": 80, "guid": {"rendered": "http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK-1.png"}, "id": 97, "link": "http://localhost:8889/10x10_e2e_test_image_z9t8jk-2/", "media_details": {"file": "2026/09/10x10_e2e_test_image_z9T8jK-1.png", "filesize": 80, "height": 10, "image_meta": {"alt": "", "aperture": "0", "camera": "", "caption": "", "copyright": "", "created_timestamp": "0", "credit": "", "focal_length": "0", "iso": "0", "keywords": [], "orientation": "0", "shutter_speed": "0", "title": ""}, "sizes": {}, "width": 10}, "media_type": "image", "meta": [], "mime_type": "image/png", "modified": "2026-09-09T20:58:04", "modified_gmt": "2026-09-09T20:58:04", "ping_status": "closed", "post": null, "slug": "10x10_e2e_test_image_z9t8jk-2", "source_url": "http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK-1.png", "status": "inherit", "template": "", "title": {"rendered": "10x10_e2e_test_image_z9T8jK"}, "type": "attachment"}, {"_links": {"about": [{"href": "http://localhost:8889/wp-json/wp/v2/types/attachment"}], "author": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/users/1"}], "collection": [{"href": "http://localhost:8889/wp-json/wp/v2/media"}], "replies": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/comments?post=93"}], "self": [{"href": "http://localhost:8889/wp-json/wp/v2/media/93", "targetHints": {"allow": ["GET", "POST", "PUT", "PATCH", "DELETE"]}}]}, "alt_text": "", "author": 1, "caption": {"rendered": ""}, "class_list": ["post-93", "attachment", "type-attachment", "status-inherit", "hentry", "entry"], "comment_status": "open", "date": "2026-09-09T20:57:45", "date_gmt": "2026-09-09T20:57:45", "description": {"rendered": "<p class=\"attachment\"><a href='http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK.png'><img loading=\"lazy\" decoding=\"async\" width=\"10\" height=\"10\" src=\"http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK.png\" class=\"attachment-medium size-medium\" alt=\"\" style=\"width:100%;height:100%;max-width:10px;\" /></a></p>
"}, "featured_media": 0, "filename": "10x10_e2e_test_image_z9T8jK.png", "filesize": 80, "guid": {"rendered": "http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK.png"}, "id": 93, "link": "http://localhost:8889/10x10_e2e_test_image_z9t8jk/", "media_details": {"file": "2026/09/10x10_e2e_test_image_z9T8jK.png", "filesize": 80, "height": 10, "image_meta": {"alt": "", "aperture": "0", "camera": "", "caption": "", "copyright": "", "created_timestamp": "0", "credit": "", "focal_length": "0", "iso": "0", "keywords": [], "orientation": "0", "shutter_speed": "0", "title": ""}, "sizes": {}, "width": 10}, "media_type": "image", "meta": [], "mime_type": "image/png", "modified": "2026-09-09T20:57:45", "modified_gmt": "2026-09-09T20:57:45", "ping_status": "closed", "post": null, "slug": "10x10_e2e_test_image_z9t8jk", "source_url": "http://localhost:8889/wp-content/uploads/2026/09/10x10_e2e_test_image_z9T8jK.png", "status": "inherit", "template": "", "title": {"rendered": "10x10_e2e_test_image_z9T8jK"}, "type": "attachment"}]
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js:71:45

From d406ce7, not the current head. Run

Comment thread packages/components/src/context/wordpress-component.ts
@github-actions github-actions Bot added the [Package] DataViews /packages/dataviews label Sep 10, 2026
selector?: `.${ string }`;
};

type RefProps< ForwardsRef extends boolean > = ForwardsRef extends true

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.

Looking at the manifest checks, it looks like key has now become an actual Dropdown prop, meaning that React.RefAttributes also adds the reserved key attribute.

Should we make RefProps add only ref, then regenerate the manifest to confirm the error is gone?


### TypeScript

- Fix internal `WordPressComponent` polymorphic typings to avoid unsupported `as` props unintentionally surfacing ([#82704](https://github.com/WordPress/gutenberg/pull/82704)).

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.

This PR needs a rebase + moving this entry under the new unreleased section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Package] DataViews /packages/dataviews [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants