Open EmmanueleVilla opened 4 years ago
Update: it seems that using "switchMap" it's what's causing the error.
As per the issue description, this doesn't work:
export const test1: Epic<RootAction, RootAction, RootState> = (action$, _state$, {}) => {
return action$.pipe(
filter(isActionOf(homeActions.homeLoadListingAction.request)),
switchMap(_action => of(homeActions.homeLoadSectionAction.success([]))),
);
};
I've tried to remove the filter and it still doesn't work:
export const test2: Epic<RootAction, RootAction, RootState> = (action$, _state$, {}) => {
return action$.pipe(
switchMap(_action => of(homeActions.homeLoadSectionAction.success([]))),
);
};
But if I remove the switchMap, it works:
export const test1: Epic<RootAction, RootAction, RootState> = (action$, _state$, {}) => {
return of(homeActions.homeLoadSectionAction.success([]));
};
So the return type seems correct
Update: I've changed the tsconfig from
"target": "es5"
to
"target": "esnext"
and now it works. Do you know why it doesn't work on es5? Should it?
Description
When intercepting an asyncAction with an epic, I got a compiler error that it's also present on your sample application in the codesandbox
Mandatory info
[ ] Are you extending internal types to enable type-free syntax with
createReducer
? No[ ] Did you checked [compatibility notes][1] and [migration guides][2]? Yes
How to Reproduce
CodeSandbox Link
I do not have a personal codesandbox link, but the exact same error is present in your codesandbox link (https://codesandbox.io/s/github/piotrwitek/typesafe-actions/tree/master/codesandbox) in the file src/feature/todos/epic:
Expected behavior
Typescript compiles since the return type is correct
Suggested solution(s)
Project Dependencies