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
typescript: ofType loses type information #187
Comments
Hm, that's really a weird behavior. But I am not sure that it's I tried the following:
(1) ist not really applicable, because As a workaround you can do the following: import { Epic } from 'redux-observable';
type FirstAction = {
type: 'First_Action'
};
type SecondAction = {
type: 'Second_Action'
};
type MyActions = FirstAction | SecondAction;
interface MyState {
field: string;
}
export const myEpic: Epic<MyActions, MyState> = (action$, store) =>
action$.ofType('First_Action')
.map<FirstAction, SecondAction>(action => ({ type: 'Second_Action' })); Not the best solution, but the good thing is that it's even more explicit than having |
In my experience, every time I try to blame a type inference problem on TypeScript, it's usually in my code somewhere. I'll do some experimenting and see if I can track this down. |
@billba whoops! I can confirm. I believe I found the problem and the solution. PR #208 Can you go into your - lift(operator: Operator<any, T>): ActionsObservable<T>;
+ lift<R>(operator: Operator<T, R>): ActionsObservable<R>; Now sure wtf I was thinking when I set it as |
I swear I tried that and it didn't work and then you tried it and it did work. WHAT ELDRITCH MAGIC DO YOU WIELD @jayphelps? |
This explains so much. |
@jayphelps Has this magical creature some time to spare and can make a 0.14.1 release for all those TypeScript users!? 😃 |
@sebald done. |
What is the current behavior?
Given the following:
In TypeScript-aware editor (e.g. VS Code) mouse over the
action
parameter in themap
. It showsaction:any
.What is the expected behavior?
Should show
action:MyActions
.Mousing over
action$
shows the correct type ofActionsObservable<MyActions>
.Weirdy, mousing over
ofType
itself shows the correct result type ofActionsObservable<MyActions>
Which versions of redux-observable, and which browser and OS are affected by this issue? Did this work in previous versions of redux-observable?
v13.0.0 - this has been with us since at least the previous release
The text was updated successfully, but these errors were encountered: