reactjs - Typescript 编译器无法检查 react-redux 连接 HOC
问题描述
我有与此类似的代码: https://codesandbox.io/s/react-typescript-q0yrc?file=/src/test.tsx (这是来自 D. Abramov示例)
但是我的 PHP Storm (IDE) 没有报告任何错误,也没有提供有关 PretendedImport 组件道具的提示。我得到的 PretendedImport 的类型提示是:
const PretendedImport: NamedExoticComponent<JSX.LibraryManagedAttributes<MyComponent, Omit<Readonly<... & ...> | (<...>(component: ...) => ... extends ...<..., ...> ? TInjectedProps : never & {backgroundColor: string, sthElse: number}) | (...<...> & ...<...>), never> & {}>> & hoistNonReactStatics.NonReactStatics<MyComponent> & {WrappedComponent: MyComponent}
我使用 create react app 创建了一个全新的 react typescript 项目,一切正常。
我试过: * 使用相同的 tsconfig.json * 使用相同的版本:TS、@types/react、@types/react-redux,* 甚至修补 webpack、babel 及其解析器(尽管这不应该相关)
我还能尝试什么让它发挥作用?我不知道是什么导致了这种差异。其他 TS 用例的编译工作。
解决方案
推荐阅读
- javascript - 如何过滤棱镜中的布尔值
- ios - 如何将默认 iOS 元素解析为特定特征?
- django - 如何使用 Djangorestframework 中的 UpdateAPIView 更新模型中的单个字段?
- angular - 如何动态呈现信息窗口内容
- python - 按值选择多列
- mongodb - Mongo DB 更新在 NiFi 中保留不常见的字段
- python - 有没有办法创建一个运行 Python 和 R 脚本的可执行文件?
- css - 选中时复选框的交叉标签
- android - 我在片段中使用了 MVVM,但是当我单击后退按钮时它不会转到上一个片段?
- django - 使用模板显示用户的组名