[docs-utils] 4️⃣ Complete ReactElement signature fix#250814
Merged
clintandrewhall merged 2 commits intoelastic:mainfrom Feb 10, 2026
Merged
[docs-utils] 4️⃣ Complete ReactElement signature fix#250814clintandrewhall merged 2 commits intoelastic:mainfrom
clintandrewhall merged 2 commits intoelastic:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR normalizes ReactElement type signatures in generated API documentation by removing the verbose second generic parameter (string | React.JSXElementConstructor<any>) while preserving the meaningful first type parameter. This makes the documentation more readable without losing important type information.
Changes:
- Added
normalizeReactElementSignature()helper function inget_signature.tsto clean upReactElementsignatures - Introduced
IssuesByPlugininterface to group issue-related parameters and refactoredcollectApiStatsForPlugin()to accept a single issues object instead of three separate parameters - Re-enabled the previously skipped
Test ReactElement signaturetest and updated integration test snapshots to reflect the normalized output
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/kbn-docs-utils/src/types.ts |
Added IssuesByPlugin interface to bundle issue-related data structures |
packages/kbn-docs-utils/src/stats.ts |
Refactored collectApiStatsForPlugin() to accept IssuesByPlugin parameter and added JSDoc comment |
packages/kbn-docs-utils/src/stats.test.ts |
Updated all test calls to use the new IssuesByPlugin parameter format and added createEmptyIssues() helper |
packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_b.mdx |
Updated date metadata in snapshot |
packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a_foo.mdx |
Updated date metadata in snapshot |
packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a.mdx |
Updated date metadata in snapshot |
packages/kbn-docs-utils/src/integration_tests/snapshots/plugin_a.devdocs.json |
Updated ReactElement signature to normalized format in JSON snapshot |
packages/kbn-docs-utils/src/integration_tests/api_doc_suite.test.ts |
Updated test expectations to match normalized ReactElement signature and refactored test setup calls |
packages/kbn-docs-utils/src/cli/tasks/collect_stats.ts |
Updated function call to use new IssuesByPlugin parameter format |
packages/kbn-docs-utils/src/build_api_declarations/get_signature.ts |
Added normalizeReactElementSignature() function that strips verbose second generic from ReactElement types |
packages/kbn-docs-utils/src/build_api_declarations/build_api_declaration.test.ts |
Re-enabled previously skipped Test ReactElement signature test |
packages/kbn-docs-utils/src/README.md |
Improved formatting and documentation structure with clearer section headers and validation rules |
13 tasks
mistic
reviewed
Feb 4, 2026
packages/kbn-docs-utils/src/build_api_declarations/get_signature.ts
Outdated
Show resolved
Hide resolved
mistic
approved these changes
Feb 4, 2026
Contributor
mistic
left a comment
There was a problem hiding this comment.
just a small comment. There are things from the pre-req PR that I haven't looked at because they will disappear once we merge it. LGTM
Contributor
|
Pinging @elastic/kibana-operations (Team:Operations) |
- Implement handling for ReactElement signatures. - Unskip and fix Test ReactElement signature test.
1e531c2 to
9777309
Compare
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.
Summary
Fixes #120125 by normalizing
ReactElementsignatures in generated API documentation.ReactElementtypes were expanding to include verbose second generic parameters likeReactElement<MyProps, string | React.JSXElementConstructor<any>>, making documentation difficult to read. This PR adds anormalizeReactElementSignaturehelper that strips the redundant second generic while preserving the meaningful first type parameter.Note
This PR is a subset of #247688 for ease of review.
This PR was written with Cursor and
claude-4.5-opus-high.Important
This PR relies on #250810 and includes it as its base commit. This PR will remain draft until that PR is merged and this branch is rebased.
Before / After Example
Given this TypeScript type:
Before this PR:
The generated API docs expanded to verbose, hard-to-read signatures:
{ "label": "AReactElementFn", "signature": [ "() => React.ReactElement<", { "pluginId": "pluginA", "section": "def-public.MyProps", "text": "MyProps" }, ", string | React.JSXElementConstructor<any>>" // <-- Verbose noise! ] }This rendered in the docs as:
After this PR:
The redundant second generic is stripped for cleaner output:
{ "label": "AReactElementFn", "signature": [ "() => React.ReactElement<", { "pluginId": "pluginA", "section": "def-public.MyProps", "text": "MyProps" }, ">" // ✅ Clean! ] }This now renders in the docs as:
Why This Matters
The second generic parameter of
ReactElement(string | React.JSXElementConstructor<any>) is a TypeScript implementation detail that:Changes
normalizeReactElementSignature()inget_signature.tsto clean upReactElementoutput before reference extractionTest ReactElement signaturetest