-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-redux types give errors when used as decorators #20796
Comments
This could be related to Decorators do not recognize class inheritance. There, someone says this:
Will it work if you change to this? class MyComponent extends React.Component<any, any> {
// ...
}
export connect(mapStateToProps)(MyComponent) // EDIT: Oops, that's invalid syntax. Please see comments below. |
so this works indeed: export const x = connect(mapStateToProps)(MyComponent); this results in an error : export connect(mapStateToProps)(MyComponent)
|
The second one is invalid syntax. |
i thought so too. |
This is a known issue: #9951 due to a limitation in the Typescript language. |
i added a comment regarding this issue to the definition file. |
try using @(connect(mapStateToProps) as any) . it will work ;) |
正解!Good! |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
@types/react-redux
package and had problems.Using typescript 2.5.3
Code to reproduce the error:
Error Msg:
Currently to make this error go away, the signature of render() method of MyComponent needs to be modified like this:
This change of signature should not be required in code by the type definition.
The text was updated successfully, but these errors were encountered: