Edit:这是 4.8.x 的打字错误,升级到 4.9.0+ 即可解决该问题。
上版本4.8.0
,以下代码编译并运行良好:
<DialogContent>
{/* use a span so we can nest div, p, etc. */}
<DialogContentText component="span">
{confirmContent}
</DialogContentText>
</DialogContent>
升级到后4.8.1
该代码现在无法进行类型检查:
No overload matches this call.
Overload 1 of 2, '(props: DialogContentTextProps, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, a
ny, any>)> | null) | (new (props: any) => Component<...>)> | Component<...> | null', gave the following error.
Type '{ children: Element; component: string; }' is not assignable to type 'IntrinsicAttributes & DialogContentTextProps'.
Property 'component' does not exist on type 'IntrinsicAttributes & DialogContentTextProps'.
Overload 2 of 2, '(props: PropsWithChildren<DialogContentTextProps>, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any)
=> Component<...>)> | null) | (new (props: any) => Component<...>)> | Component<...> | null', gave the following error.
Type '{ children: Element; component: string; }' is not assignable to type 'IntrinsicAttributes & DialogContentTextProps & { children?: ReactNode; }'.
Property 'component' does not exist on type 'IntrinsicAttributes & DialogContentTextProps & { children?: ReactNode; }'. TS2769
我可以通过删除来重新编译我的项目component="span"
部分 - 但正确的解决办法是什么?
指定指定所使用的基本组件的新方法是什么DialogContentText
?
我的项目是一个标准create-react-app
设置,使用Typescript
3.7.4
.