Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Typescript对最新样式的组件抛出错误_Reactjs_Typescript_Styled Components - Fatal编程技术网

Reactjs Typescript对最新样式的组件抛出错误

Reactjs Typescript对最新样式的组件抛出错误,reactjs,typescript,styled-components,Reactjs,Typescript,Styled Components,我有一个使用React、TypeScript和样式化组件的项目。我在这个项目上工作了一段时间,然后决定将样式化组件升级到最新版本,即5.1.1(以前是2.4.1)。 因此,项目可以正常编译和运行,但当我尝试实际构建它时,它会抛出以下错误: node_modules/@types/styled-components/ts3.7/index.d.ts:151:69 - error TS2694: Namespace '"C:/path/node_modules/hoist-non-rea

我有一个使用React、TypeScript和样式化组件的项目。我在这个项目上工作了一段时间,然后决定将样式化组件升级到最新版本,即
5.1.1
(以前是
2.4.1
)。 因此,项目可以正常编译和运行,但当我尝试实际构建它时,它会抛出以下错误:

node_modules/@types/styled-components/ts3.7/index.d.ts:151:69 - error TS2694: 
Namespace '"C:/path/node_modules/hoist-non-react-statics/index"' has no exported member 'NonReactStatics'.

151     string & StyledComponentBase<C, T, O, A> & 
hoistNonReactStatics.NonReactStatics<C extends React.ComponentType<any> ? C : never>;
node_modules/@types/styled components/ts3.7/index.d.ts:151:69-错误TS2694:
命名空间“C:/path/node_modules/hugh non-react statics/index”没有导出的成员“nonreact statics”。
151 string&StyledComponentBase&
非反应性药物;非反应性药物;
node_modules/@types/styled components/ts3.7/index.d.ts:253:65-错误TS2344:
类型“C”不满足约束“ComponentType”。
类型“ElementType”不可分配给类型“ComponentType”。
类型“symbol”不可分配给类型“ComponentType”。
类型“C”不可分配给类型“FunctionComponent”。
类型“ElementType”不可分配给类型“FunctionComponent”。
类型“symbol”不可分配给类型“FunctionComponent”。
253     ? React.componentpropertswithref
我尝试了不同版本的TypeScript、较旧版本的样式化组件和较新版本的Node.js,但所有这些都会给我带来各种各样的错误。一些设置只抛出两个错误,其他设置抛出15个错误。 如果有助于理解问题,我可以附加我的
tsconfig.json
。 我的打字脚本版本目前是
3.7。

据我所知,样式化组件用于满足其需求的包中存在一些不兼容之处。但我不知道如何修复它们

node_modules/@types/styled-components/ts3.7/index.d.ts:253:65 - error TS2344: 
Type 'C' does not satisfy the constraint 'ComponentType<any>'.
  Type 'ElementType<any>' is not assignable to type 'ComponentType<any>'.
    Type '"symbol"' is not assignable to type 'ComponentType<any>'.
      Type 'C' is not assignable to type 'FunctionComponent<any>'.
        Type 'ElementType<any>' is not assignable to type 'FunctionComponent<any>'.
          Type '"symbol"' is not assignable to type 'FunctionComponent<any>'.

253     ? React.ComponentPropsWithRef<StyledComponentInnerComponent<C>>