rax icon indicating copy to clipboard operation
rax copied to clipboard

[Question]如何消除meet的form不能用作 JSX 组件的类型提示

Open xmsz opened this issue 3 years ago • 1 comments

背景

  • 默认项目模板
  • typescript 4.6.2
 <Form />

提示

“Form”不能用作 JSX 组件。
  其实例类型 "Form" 不是有效的 JSX 元素。
    属性“refs”的类型不兼容。
      不能将类型“{ [key: string]: RaxInstance; }”分配给类型“{ [key: string]: ReactInstance; }”。
        “string”索引签名不兼容。
          不能将类型“RaxInstance”分配给类型“ReactInstance”。
            不能将类型“Component<any, {}, any>”分配给类型“ReactInstance”。
              不能将类型“Rax.Component<any, {}, any>”分配给类型“React.Component<any, {}, any>”。
                在这些类型中,"render()" 返回的类型不兼容。
                  不能将类型“RaxNode”分配给类型“ReactNode”。
                    不能将类型“{}”分配给类型“ReactNode”。ts(2786)
<InputField  />

提示

“InputField”不能用作 JSX 组件。
  其实例类型 "InputField" 不是有效的 JSX 元素。
    属性“refs”的类型不兼容。
      不能将类型“{ [key: string]: RaxInstance; }”分配给类型“{ [key: string]: ReactInstance; }”。
        “string”索引签名不兼容。
          不能将类型“RaxInstance”分配给类型“ReactInstance”。ts(2786)

需求

  • 如何消除这类提示

xmsz avatar May 27 '22 09:05 xmsz

这个应该是由于项目中的@types/react为18造成的

临时解决办法 在package.json加上

    "resolutions": {
        "@types/react": "17.0.45"
    }

xmsz avatar May 30 '22 02:05 xmsz