I have a redux observable epic
as below
export const fetchUserEpic:Epic<Action, RootState, any> =
(action$: ActionsObservable<Action>, store: MiddlewareAPI<RootState> , { getJSON } ): Observable<Action> =>
action$.filter((action: Action) => action.type === actionTypes.FETCH_USER)
.mergeMap( (action: Action) =>
getJSON(`/api/user/${action.payload}`)
.map((response: any) => Actions.fetchUserSuccess(response))
)
Everything works fine and the tests are great, but on compiling the typescript code, I get the following warning
semantic error TS6133 'store' is declared but its value is never read.
How do I resolve this issue
It's a linting error from TypeScript noUnusedParameters aka no-unused-variable setting. It means that your function has the store
parameter defined but does not actually use it. To fix you can prefix the store parameter with an underscore _store
and it will ignore it, or you can remove the linting option from either your tsconfig or your compiler flags.
(action$: ActionsObservable<Action>, _store: MiddlewareAPI<RootState> , { getJSON } ): Observable<Action>
This works because the TypeScript compiler explicitly added this convention as an exception to the linting rule. It was done for exactly these sorts of cases.