-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Error in types for middleware (typescript 2.4.1) #2481
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
Comments
Just merged this in yesterday: #2467 |
Sorry, this is all sort of a mess and I'm not well-versed in TS. Is #2483 related? |
@artem-malko could you test this pr #2479 with [email protected], it works well in my project. |
@timdorr I understand. No #2483 is about reducers too, not about middleware)
And if I change code to:
It has errors too:
|
@artem-malko after [email protected] change the generics check, Middleware should change the position of export interface Middleware<S> {
(api: MiddlewareAPI<S>): (next: Dispatch<S>) => Dispatch<S>;
} |
Most middlewares can work regardless of state type, so in these cases, it's not a type parameter of As you can see in typings for Store enhancers, there are two versions: one for fixed state type, and one generic. I think we should follow the same approach for middleware. |
I have the same problem and don't really know how to overcome this without forcing an My function is as small as this: http://i.imgur.com/qcxGmoj.gifv What should I do to fix this? I don't understand half of the messages above, sorry :-/ My typescript version is I have reducers correctly typed, as you can see |
@Llorx What error do you get? |
@aikoven Ok, this is weird. I had a method that accepted a Now I removed the I guess that I had a type problem elsewhere that affected here. I thought that the IDE should show |
I can reproduce the error:
I tried to change the typings for TypeScript: 2.4.2 |
This is my workaround for now:
@timdorr Shouldn't we reopen this until it is fixed? |
Please reopen, this is not fixed yet. I still have the same error too TypeScript: 2.4.2 |
Can someone work up a fix PR? |
Should be fixed by #2563 |
Is it possible to add an example of what a valid middleware would look like with typescript? Even after following this thread, I'm unsure how to update my middleware so that it compiles correctly and types are satisfied. |
@macdonaldr93 See the tests for Middleware types. |
It is a bug
I have this simple middleware:
It is useless, but there is a problem) This code works with typescript version 2.3.x and below. But in typescript 2.4 there is an Error.
What is the current behavior?
In typescript I have this Error:
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar.
You can find demo code at the top of current issue.
What is the expected behavior?
I expect, that there won't be any errors.
Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?
Typescript: 2.4.1
Redux: 3.7.1
NodeJS: 6.9.1
OS: MacOS
The text was updated successfully, but these errors were encountered: