首页 > 解决方案 > 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 用例的编译工作。

标签: reactjstypescriptreact-redux

解决方案


推荐阅读