ant-design: 'Alert.ErrorBoundary' cannot be used as a JSX component.
Reproduction link
Steps to reproduce
使用最新的vite react-ts模板(node 22.12.0) 安装antd,放入<Alert.ErrorBoundary/>组件 运行tsc -b
What is expected?
返回0
What is actually happening?
src/App.tsx:7:8 - error TS2786: 'Alert.ErrorBoundary' cannot be used as a JSX component.
Its type 'typeof ErrorBoundary' is not a valid JSX element type.
Type 'typeof ErrorBoundary' is not assignable to type 'new (props: any, deprecatedLegacyContext?: any) => Component<any, any, any>'.
Construct signature return types 'ErrorBoundary' and 'Component<any, any, any>' are incompatible.
The types returned by 'render()' are incompatible between these types.
Type 'string | number | bigint | boolean | Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | ReactPortal | Iterable<ReactNode> | ReactElement<...> | null | undefined> | null | undefined' is not assignable to type 'ReactNode'.
Type 'bigint' is not assignable to type 'ReactNode'.
7 <Alert.ErrorBoundary/>
~~~~~~~~~~~~~~~~~~~
Found 1 error.
| Environment | Info |
|---|---|
| antd | 5.22.7 |
| React | 18.3.1 |
| System | Windows 11 |
| Browser | 无 |
package.json
"dependencies": {
"antd": "^5.22.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.17.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.14.0",
"typescript": "~5.6.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.5"
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (11 by maintainers)
The problem still exists in version 5.24.0. Is there any plan to fix it? My repository uses many npm packages, some of which are not yet compatible with React version 19, so I cannot upgrade my repository. Please, can you fix this error?
I confirm that this error occurs with version 5.22.6 on React 18.3.1
Upgrading to v5.23.3 still getting this error! Pls solved this
@afc163 can you review my PR? Thank you.
@afc163 Even in your demo here there is the same compilation error. Open the demo in stackblitz:
import ErrorBoundary from 'antd/lib/alert/ErrorBoundary';also not working, becausebigintinErrorBoundary.render()oflib/alert/ErrorBoundary.d.tsdoes not match typeReactNodein@types/react 18.xUpdating to React 19 resolves the error