我在某些包的打字稿项目中遇到了这些奇怪的类型错误。前任:
'TimeAgo' cannot be used as a JSX component.
Its instance type 'ReactTimeago<keyof IntrinsicElements | ComponentType<{}>>' is not a valid JSX element.
The types returned by 'render()' are incompatible between these types.
Type 'React.ReactNode' is not assignable to type 'import("/home/user/app/node_modules/@types/react-bootstrap-table-next/node_modules/@types/react/index").ReactNode'.
Type '{}' is not assignable to type 'ReactNode'.
Run Code Online (Sandbox Code Playgroud)
我在本地 Windows 计算机上没有遇到这些类型错误,但它们在我的 Linux 虚拟机中不断发生。我已经多次删除该项目,克隆我的存储库并在不同版本的节点中再次安装软件包,但仍然遇到相同类型的错误。
已检查节点12.18.3、16.13.1
以下是一些快速包 json 信息:
"react-timeago": "^6.2.1",
"react-custom-scrollbars": "^4.2.1",
"react-custom-scrollbars-2": "^4.4.0",
"react": "^17.0.2",
"next": "^12.1.1",
"@types/react-custom-scrollbars": "^4.0.10",
"@types/react-timeago": "^4.1.3",
"@types/react": "^17.0.44",
"typescript": "^4.3.5"
"@types/node": "^14.18.12",
Run Code Online (Sandbox Code Playgroud)
这发生在基本的自定义组件上:
MyTst.tsx
import …Run Code Online (Sandbox Code Playgroud)