use recursive partial so we don't have to use "as"

This commit is contained in:
David Lechner
2021-01-22 10:35:11 -06:00
parent e1932febb2
commit caacaad341
4 changed files with 19 additions and 22 deletions
+6 -2
View File
@@ -5,11 +5,15 @@ import { END, MulticastChannel, Saga, Task, runSaga, stdChannel } from 'redux-sa
import { Action } from '../src/actions';
import { RootState } from '../src/reducers';
type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};
export class AsyncSaga {
private channel: MulticastChannel<Action>;
private dispatches: (Action | END)[];
private takers: { put: (action: Action | END) => void }[];
private state: Partial<RootState>;
private state: RecursivePartial<RootState>;
private task: Task;
public constructor(saga: Saga, context?: Record<string, unknown>) {
@@ -63,7 +67,7 @@ export class AsyncSaga {
return Promise.resolve(next);
}
public setState(state: Partial<RootState>): void {
public setState(state: RecursivePartial<RootState>): void {
this.state = state;
}