Skip to content

fix(eagle): imply safeReactNode to exclude {} type from ReactNode#1307

Merged
netweng merged 3 commits into
mainfrom
fix/dialog-safe-react-node-types
May 27, 2026
Merged

fix(eagle): imply safeReactNode to exclude {} type from ReactNode#1307
netweng merged 3 commits into
mainfrom
fix/dialog-safe-react-node-types

Conversation

@Sczlog
Copy link
Copy Markdown
Member

@Sczlog Sczlog commented May 25, 2026

introduce SafeReactNode type, exclude {} from native React.ReactNode which will make any object a legal input of props to avoid runtime crash.

Only replace SmallDialog component and related component, for other component, may use a stricter type like React.ReactElement, here is an summary made by AI agent that recommend to replace ReactNode with ReactElement

core Directory

File Path Interface/Component Prop Current Type Suggested Change Reason
src/core/Tab/Tab.type.ts TabProps extraSlot ReactNode ReactElement | null Action button group on the right side of the tab bar; should be a single element
src/core/Select/select.widgets.tsx OptionProps prefix ReactNode ReactElement | null Icon prefix for dropdown options
src/core/Select/select.widgets.tsx OptionProps suffix ReactNode ReactElement | null Icon suffix for dropdown options
src/core/Alert/alert.type.ts AlertProps action ReactNode ReactElement | null Action button on the right side of the message
src/core/message/message.tsx ArgsProps icon ReactNode ReactElement | null Custom message icon
src/core/Nav/nav.type.ts NavProps left ReactNode[] ReactElement[] Menu item group on the left side of the navigation bar
src/core/Nav/nav.type.ts NavProps right ReactNode[] ReactElement[] Toolbar button group on the right side of the navigation bar
src/core/Nav/nav.type.ts NavProps center ReactNode[] ReactElement[] Breadcrumb/title group in the center of the navigation bar
src/core/TableForm/types.ts RowAddConfigurations extraAction ReactNode ReactElement | null Custom action to the right of the add button
src/core/Metric/MetricActions.tsx MetricActions dropdown ReactNode ReactElement | null Dropdown menu trigger in the upper-right corner of the chart
src/core/Metric/RenderChart.tsx IChartProps dropdown ReactNode ReactElement | null Dropdown menu trigger in the chart toolbar
src/core/Overflow/index.tsx ExtraOverflow extraEl (sliceEnd) => ReactNode (sliceEnd) => ReactElement Overflow hint element (e.g. "+3 more")
src/core/Overflow/index.tsx ExtraOverflow els ReactNode[] ReactElement[] Child element list used for layout width calculation
src/core/LegacyModal/LegacyModal.type.ts LegacyModalProps closeIcon ReactNode ReactElement | null Custom close icon
src/core/ImmersiveDialog/type.ts ImmersiveDialogProps closeIcon ReactNode ReactElement | null Custom close icon
src/core/ImmersiveDialog/type.ts ImmersiveDialogProps footerLeftAction ReactNode ReactElement | null "Previous step" button on the left side of the footer
src/core/BaseIcon/index.tsx IBaseIconProps prefixNode ReactNode ReactElement | null Decorative node or badge before the icon
src/core/Icon/index.tsx IconProps prefix ReactNode ReactElement | null Badge or decorative icon prefix
src/core/Timeline/Timeline.type.ts TimelineAreaProps suffix ReactNode ReactElement | null Suffix action button for timeline items
src/core/Timeline/Timeline.type.ts TimelineItemData infoAction ReactNode ReactElement | null Action button in the main info area

coreX Directory

File Path Interface/Component Prop Current Type Suggested Change Reason
src/coreX/Dialogs/RejectDialog/RejectDialog.type.ts SingleRejectDialogProps resourceIcon ReactNode ReactElement | null Icon before resource list items
src/coreX/Dialogs/RejectDialog/RejectDialog.type.ts MultiAllRejectDialogProps resourceIcon ReactNode ReactElement | null Icon before resource list items
src/coreX/Dialogs/RejectDialog/RejectDialog.type.ts MultiPartialRejectDialogProps resourceIcon ReactNode ReactElement | null Icon before resource list items
src/coreX/InfoRowList/InfoRowList.type.ts InfoListProps.data action ReactNode ReactElement | null Action button on the right side of the info row

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

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

Project Deployment Actions Updated (UTC)
cloudtower-ui-kit Ready Ready Preview, Comment May 26, 2026 8:00am

@Sczlog
Copy link
Copy Markdown
Member Author

Sczlog commented May 25, 2026

自测可见 storybook 中错误类型章节

@Sczlog Sczlog requested review from chenenpei and netweng and removed request for netweng May 25, 2026 10:05
</div>
)}
{renderContent()}
<>
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.

这个改动是必要的么?是 AI 引入的?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

因为 beforeContent 是一个 ReactNode,不加会出错,这个替换看起来传染性有点强

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

我把因为 SmallDialog 的 prop 更新传染影响的 props 也修改了一下

@chenenpei
Copy link
Copy Markdown
Contributor

其他 LGTM。

github-actions[bot]
github-actions Bot previously approved these changes May 26, 2026
…DeleteDialog props to eliminate type contagion
@netweng
Copy link
Copy Markdown
Member

netweng commented May 26, 2026

顺便加个 lint 禁止使用 reactnode 类型吧

@Sczlog
Copy link
Copy Markdown
Member Author

Sczlog commented May 27, 2026

顺便加个 lint 禁止使用 reactnode 类型吧

现在还不行,还没统一替换,具体的统一替换我觉得单独一个 mr 提出来比较好,上面也提到了,不同 props 替换的类型可能不一样,有些应该限制到 ReactElement 比较合适

@netweng
Copy link
Copy Markdown
Member

netweng commented May 27, 2026

LGTM

@netweng netweng merged commit ec7f622 into main May 27, 2026
4 checks passed
@netweng netweng deleted the fix/dialog-safe-react-node-types branch May 27, 2026 03:38
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