react 项目构建时构建失败,报错信息如下
代码语言:javascript复制[2023-06-06 11:12:51]TS2786: 'StatusTip' cannot be used as a JSX component.
[2023-06-06 11:12:51] Its type 'FunctionComponent> & { LoadingTip: ForwardRefExoticComponent>; EmptyTip: ForwardRefExoticComponent<...>; FoundTip: ForwardRefExoticComponent<...>; ErrorTip: ForwardRefExoticComponent<...>; }' is not a valid JSX element type.
[2023-06-06 11:12:51] 29 | <>
[2023-06-06 11:12:51] 30 |
[2023-06-06 11:12:51] > 31 |
[2023-06-06 11:12:51] | ^^^^^^^^^
[2023-06-06 11:12:51] 32 |
[2023-06-06 11:12:51] 33 | );
[2023-06-06 11:12:51] 34 | }
[2023-06-06 11:12:51]src/common/LazyLoading.tsx:36:13
错误信息其实很明确,因为项目原来是好好的,在流水线中构建,突然出现的问题,肯定是构建环境问题,报错内容大概是说函数的返回值类型不能用作react组件,所以判断是ts的类型校验和我们原有项目的react版本不兼容, 所以通过同步ts的版本和react的类型声明文件的版本解决
代码语言:javascript复制yarn add -D @types/react@latest @types/react-dom@latest