Skip to content

Commit d489484

Browse files
fix(router-store): cast return type as RouterReducerState (#2887)
1 parent c5a5dd1 commit d489484

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

modules/router-store/src/reducer.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,20 @@ export type RouterReducerState<
1616
};
1717

1818
export function routerReducer<
19-
T extends BaseRouterStoreState = SerializedRouterStateSnapshot
20-
>(
21-
state: RouterReducerState<T> | undefined,
22-
action: Action
23-
): RouterReducerState<T> {
19+
RouterState extends BaseRouterStoreState = SerializedRouterStateSnapshot,
20+
Result = RouterReducerState<RouterState>
21+
>(state: Result | undefined, action: Action): Result {
2422
// Allow compilation with strictFunctionTypes - ref: #1344
25-
const routerAction = action as RouterAction<any, T>;
23+
const routerAction = action as RouterAction<any, RouterState>;
2624
switch (routerAction.type) {
2725
case ROUTER_NAVIGATION:
2826
case ROUTER_ERROR:
2927
case ROUTER_CANCEL:
30-
return {
28+
return ({
3129
state: routerAction.payload.routerState,
3230
navigationId: routerAction.payload.event.id,
33-
};
31+
} as unknown) as Result;
3432
default:
35-
return state as RouterReducerState<T>;
33+
return state as Result;
3634
}
3735
}

0 commit comments

Comments
 (0)