fix(core): Middleware type inference
MODIFY
packages/core/src/effects/effects.interface.ts
packages/core/src/effects/effects.interface.ts
@@ -8,13 +8,9 @@ export interface EffectResponse {
}
export interface Middleware<
- TBody = any,
- TParams = any,
- TQuery = any,
-> extends Effect<
- HttpRequest<TBody, TParams, TQuery>,
- HttpRequest<TBody, TParams, TQuery>
-> {}
+ I extends HttpRequest = HttpRequest,
+ O extends HttpRequest = HttpRequest,
+> extends Effect<I, O> {}
export interface ErrorEffect<T extends Error = Error>
extends Effect<HttpRequest, EffectResponse, T> {}

MODIFY
packages/core/src/operators/use/use.operator.ts
packages/core/src/operators/use/use.operator.ts
@@ -3,9 +3,9 @@ import { switchMap } from 'rxjs/operators';
import { Middleware } from '../../effects/effects.interface';
import { HttpRequest, HttpResponse } from '../../http.interface';
-export const use = <T, U, V>
- (middleware: Middleware<T, U, V>, res?: HttpResponse) =>
- (source$: Observable<HttpRequest>): Observable<HttpRequest<T, U, V>> =>
+export const use = <T extends HttpRequest>
+ (middleware: Middleware<HttpRequest, T>, res?: HttpResponse) =>
+ (source$: Observable<HttpRequest>): Observable<T> =>
source$.pipe(
switchMap(req => middleware(of(req), res!, {}))
);

fix(core): Middleware type inference