我对Typescript还是很陌生,遇到了一个我不太了解的错误。我设法解决了这个问题(我认为),但我只是很好奇能真正理解错误的含义。
这是错误:
TypeScript error in /home/js/Development/gigalixir-web/src/RegisterPage.tsx(155,42):
Argument of type 'typeof Login' is not assignable to parameter of type 'AnyComponent<Pick<StyledComponentProps<"main" | "avatar" | "icon" | "card"> & Partial<WithTheme>, "theme"> & Partial<WithTheme> & { classes: Record<"main" | "avatar" | "icon" | "card", string>; }>'.
Type 'typeof Login' is not assignable to type 'new (props: Pick<StyledComponentProps<"main" | "avatar" | "icon" | "card"> & Partial<WithTheme>, "theme"> & Partial<WithTheme> & { classes: Record<"main" | "avatar" | "icon" | "card", string>; }) => Component<...>'.
Types of parameters 'props' and 'props' are incompatible.
Property 'loginForm' is missing in type 'Pick<StyledComponentProps<"main" | "avatar" | "icon" | "card"> & Partial<WithTheme>, "theme"> & Partial<WithTheme> & { classes: Record<"main" | "avatar" | "icon" | "card", string>; }' but required in type 'Readonly<Props & Partial<WithTheme> & { classes: Record<"main" | "avatar" | "icon" | "card", string>; } & HtmlHTMLAttributes<HTMLDivElement>>'. TS2345
153 | }
154 |
> 155 | const EnhancedLogin = withStyles(styles)(Login) as ComponentType<Props>
| ^
156 |
157 | // EnhancedLogin.propTypes = {
158 | // backgroundImage: PropTypes.string,
来自this file的人。
我通过将this line上的object
更改为与this line匹配的Theme
来解决了,或者至少是这样。这些类型应该匹配对我来说很有意义,但是我想我的问题是
loginForm
有关时,为什么上面的错误提到theme
谢谢!任何帮助表示赞赏!