fix: do not expand React.CSSProperties in component API docs - #125
Merged
Conversation
React.CSSProperties is a large interface (~825 members). When a public component prop is typed as React.CSSProperties, getObjectDefinition expanded every member into the generated API definition, bloating the documenter output (~981KB per part). Treat React.CSSProperties as an opaque type reference, mirroring the existing handling of React.ReactNode, so it is emitted as its type name with no inlineType expansion.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #125 +/- ##
==========================================
+ Coverage 94.57% 94.58% +0.01%
==========================================
Files 11 11
Lines 516 517 +1
Branches 142 143 +1
==========================================
+ Hits 488 489 +1
Misses 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR prevents React.CSSProperties from being expanded into a huge inline object definition in generated component API docs, keeping the output size manageable for components that expose style?: React.CSSProperties.
Changes:
- Treat
React.CSSPropertiesas an opaque type reference ingetObjectDefinition, similar to existing handling forReact.ReactNode. - Add a new fixture component that exposes a
style?: React.CSSPropertiesprop. - Add a snapshot test to ensure the generated docs keep
React.CSSPropertiesunexpanded (inlineType: undefined).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/components/object-definition.ts |
Adds React.CSSProperties to the non-expansion allowlist so it remains a simple type reference in docs output. |
fixtures/components/css-properties/tsconfig.json |
Adds a dedicated fixture project configuration for the new css-properties test case. |
fixtures/components/css-properties/box/index.tsx |
Introduces a minimal fixture component with style?: React.CSSProperties to reproduce and validate the behavior. |
test/components/css-properties.test.ts |
Adds a Vitest snapshot test covering the non-expansion behavior. |
test/components/__snapshots__/css-properties.test.ts.snap |
Captures the expected output showing type: React.CSSProperties with no inlineType expansion. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
avinashbot
approved these changes
Aug 28, 2026
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.
Problem
When a public component prop is typed as
React.CSSProperties,getObjectDefinitionfalls through to the object-expansion branch and inlines every member of the interface (~825 properties) into the generated API definition. For a single such prop this bloats the documenter output to ~981KB per component part.No shipped component currently exposes
React.CSSPropertiespublicly (SplitPanel's is on an internal, non-exported interface), but an upcoming component (BasicTable) exposesstyle?: React.CSSPropertieson its body and row parts for bring-your-own virtualization, which surfaces this.Fix
Treat
React.CSSPropertiesas an opaque type reference — exactly howReact.ReactNodeandHTMLElementare already handled in the same allowlist. The documenter now emits it as its type name (React.CSSProperties) with noinlineTypeexpansion.realTypeName.split('.')[0] === 'Highcharts' || - type === 'React.ReactNode' + type === 'React.ReactNode' || + type === 'React.CSSProperties' ) { // do not expand built-in Javascript methods or primitive values return { type };The match string
'React.CSSProperties'was confirmed empirically against@types/react—stringifyType(withUseFullyQualifiedType) produces exactlyReact.CSSProperties, matching the existingReact.ReactNodeconvention.Testing
fixtures/components/css-propertiesand snapshot testcss-properties.test.tsasserting astyle?: React.CSSPropertiesprop documents as{ type: 'React.CSSProperties', inlineType: undefined }(before this change it expanded to 825 properties).npm run lintandnpm run buildclean.