This commit is contained in:
Nathan Bierema 2020-05-17 00:34:49 -04:00
parent 3b9d9443fb
commit 5cc660ff7c
2 changed files with 200 additions and 87 deletions

View File

@ -96,9 +96,9 @@ interface JumpToActionAction {
actionId: number; actionId: number;
} }
interface ImportStateAction<S, A extends Action<unknown>> { interface ImportStateAction<S, A extends Action<unknown>, MonitorState> {
type: typeof ActionTypes.IMPORT_STATE; type: typeof ActionTypes.IMPORT_STATE;
nextLiftedState: LiftedState<S, A> | readonly A[]; nextLiftedState: LiftedState<S, A, MonitorState> | readonly A[];
preloadedState?: S; preloadedState?: S;
noRecompute: boolean | undefined; noRecompute: boolean | undefined;
} }
@ -113,7 +113,12 @@ interface PauseRecordingAction {
status: boolean; status: boolean;
} }
export type LiftedAction<S, A extends Action<unknown>> = export type LiftedAction<
S,
A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
> =
| PerformAction<A> | PerformAction<A>
| ResetAction | ResetAction
| RollbackAction | RollbackAction
@ -124,7 +129,7 @@ export type LiftedAction<S, A extends Action<unknown>> =
| ReorderAction | ReorderAction
| JumpToStateAction | JumpToStateAction
| JumpToActionAction | JumpToActionAction
| ImportStateAction<S, A> | ImportStateAction<S, A, MonitorState>
| LockChangesAction | LockChangesAction
| PauseRecordingAction; | PauseRecordingAction;
@ -242,10 +247,10 @@ export const ActionCreators = {
return { type: ActionTypes.JUMP_TO_ACTION, actionId }; return { type: ActionTypes.JUMP_TO_ACTION, actionId };
}, },
importState<S, A extends Action<unknown>>( importState<S, A extends Action<unknown>, MonitorState>(
nextLiftedState: LiftedState<S, A> | readonly A[], nextLiftedState: LiftedState<S, A, MonitorState> | readonly A[],
noRecompute?: boolean noRecompute?: boolean
): ImportStateAction<S, A> { ): ImportStateAction<S, A, MonitorState> {
return { type: ActionTypes.IMPORT_STATE, nextLiftedState, noRecompute }; return { type: ActionTypes.IMPORT_STATE, nextLiftedState, noRecompute };
}, },
@ -371,7 +376,7 @@ export function liftAction<A extends Action<unknown>>(
traceLimit?: number, traceLimit?: number,
toExcludeFromTrace?: Function toExcludeFromTrace?: Function
): PerformAction<A> { ): PerformAction<A> {
return ActionCreators.performAction<A>( return ActionCreators.performAction(
action, action,
trace, trace,
traceLimit, traceLimit,
@ -379,8 +384,14 @@ export function liftAction<A extends Action<unknown>>(
); );
} }
export interface LiftedState<S, A extends Action<unknown>> { function isArray<S, A extends Action<unknown>, MonitorState>(
monitorState: unknown; nextLiftedState: LiftedState<S, A, MonitorState> | readonly A[]
): nextLiftedState is readonly A[] {
return Array.isArray(nextLiftedState);
}
export interface LiftedState<S, A extends Action<unknown>, MonitorState> {
monitorState: MonitorState;
nextActionId: number; nextActionId: number;
actionsById: { [actionId: number]: PerformAction<A> }; actionsById: { [actionId: number]: PerformAction<A> };
stagedActionIds: number[]; stagedActionIds: number[];
@ -392,25 +403,27 @@ export interface LiftedState<S, A extends Action<unknown>> {
isPaused: boolean; isPaused: boolean;
} }
function isArray<S, A extends Action<unknown>>(
nextLiftedState: LiftedState<S, A> | readonly A[]
): nextLiftedState is readonly A[] {
return Array.isArray(nextLiftedState);
}
/** /**
* Creates a history state reducer from an app's reducer. * Creates a history state reducer from an app's reducer.
*/ */
export function liftReducerWith<S, A extends Action<unknown>>( export function liftReducerWith<
S,
A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
>(
reducer: Reducer<S, A>, reducer: Reducer<S, A>,
initialCommittedState: PreloadedState<S> | undefined, initialCommittedState: PreloadedState<S> | undefined,
monitorReducer: Reducer<unknown, Action<unknown>>, monitorReducer: Reducer<MonitorState, MonitorAction>,
options: Options<S, A> options: Options<S, A, MonitorState, MonitorAction>
): Reducer<LiftedState<S, A>, LiftedAction<S, A>> { ): Reducer<
const initialLiftedState: LiftedState<S, A> = { LiftedState<S, A, MonitorState>,
monitorState: monitorReducer(undefined, {} as Action<unknown>), LiftedAction<S, A, MonitorState, MonitorAction>
> {
const initialLiftedState: LiftedState<S, A, MonitorState> = {
monitorState: monitorReducer(undefined, {} as MonitorAction),
nextActionId: 1, nextActionId: 1,
actionsById: { 0: liftAction<A>(INIT_ACTION as A) }, actionsById: { 0: liftAction(INIT_ACTION as A) },
stagedActionIds: [0], stagedActionIds: [0],
skippedActionIds: [], skippedActionIds: [],
committedState: initialCommittedState as S, committedState: initialCommittedState as S,
@ -424,9 +437,9 @@ export function liftReducerWith<S, A extends Action<unknown>>(
* Manages how the history actions modify the history state. * Manages how the history actions modify the history state.
*/ */
return ( return (
liftedState: LiftedState<S, A> | undefined, liftedState: LiftedState<S, A, MonitorState> | undefined,
liftedAction: LiftedAction<S, A> liftedAction: LiftedAction<S, A, MonitorState, MonitorAction>
): LiftedState<S, A> => { ): LiftedState<S, A, MonitorState> => {
let { let {
monitorState, monitorState,
actionsById, actionsById,
@ -471,11 +484,16 @@ export function liftReducerWith<S, A extends Action<unknown>>(
currentStateIndex > excess ? currentStateIndex - excess : 0; currentStateIndex > excess ? currentStateIndex - excess : 0;
} }
function computePausedAction(shouldInit?: boolean): LiftedState<S, A> { function computePausedAction(
shouldInit?: boolean
): LiftedState<S, A, MonitorState> {
let computedState; let computedState;
if (shouldInit) { if (shouldInit) {
computedState = computedStates[currentStateIndex]; computedState = computedStates[currentStateIndex];
monitorState = monitorReducer(monitorState, liftedAction); monitorState = monitorReducer(
monitorState,
liftedAction as MonitorAction
);
} else { } else {
computedState = computeNextEntry( computedState = computeNextEntry(
reducer, reducer,
@ -487,7 +505,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
if (!options.pauseActionType || nextActionId === 1) { if (!options.pauseActionType || nextActionId === 1) {
return { return {
monitorState, monitorState,
actionsById: { 0: liftAction<A>(INIT_ACTION as A) }, actionsById: { 0: liftAction(INIT_ACTION as A) },
nextActionId: 1, nextActionId: 1,
stagedActionIds: [0], stagedActionIds: [0],
skippedActionIds: [], skippedActionIds: [],
@ -509,7 +527,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
monitorState, monitorState,
actionsById: { actionsById: {
...actionsById, ...actionsById,
[nextActionId - 1]: liftAction<A>({ [nextActionId - 1]: liftAction({
type: options.pauseActionType type: options.pauseActionType
} as A) } as A)
}, },
@ -539,7 +557,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
if (/^@@redux\/(INIT|REPLACE)/.test(liftedAction.type)) { if (/^@@redux\/(INIT|REPLACE)/.test(liftedAction.type)) {
if (options.shouldHotReload === false) { if (options.shouldHotReload === false) {
actionsById = { 0: liftAction<A>(INIT_ACTION as A) }; actionsById = { 0: liftAction(INIT_ACTION as A) };
nextActionId = 1; nextActionId = 1;
stagedActionIds = [0]; stagedActionIds = [0];
skippedActionIds = []; skippedActionIds = [];
@ -597,7 +615,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
} }
case ActionTypes.RESET: { case ActionTypes.RESET: {
// Get back to the state the store was created with. // Get back to the state the store was created with.
actionsById = { 0: liftAction<A>(INIT_ACTION as A) }; actionsById = { 0: liftAction(INIT_ACTION as A) };
nextActionId = 1; nextActionId = 1;
stagedActionIds = [0]; stagedActionIds = [0];
skippedActionIds = []; skippedActionIds = [];
@ -609,7 +627,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
case ActionTypes.COMMIT: { case ActionTypes.COMMIT: {
// Consider the last committed state the new starting point. // Consider the last committed state the new starting point.
// Squash any staged actions into a single committed state. // Squash any staged actions into a single committed state.
actionsById = { 0: liftAction<A>(INIT_ACTION as A) }; actionsById = { 0: liftAction(INIT_ACTION as A) };
nextActionId = 1; nextActionId = 1;
stagedActionIds = [0]; stagedActionIds = [0];
skippedActionIds = []; skippedActionIds = [];
@ -621,7 +639,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
case ActionTypes.ROLLBACK: { case ActionTypes.ROLLBACK: {
// Forget about any staged actions. // Forget about any staged actions.
// Start again from the last committed state. // Start again from the last committed state.
actionsById = { 0: liftAction<A>(INIT_ACTION as A) }; actionsById = { 0: liftAction(INIT_ACTION as A) };
nextActionId = 1; nextActionId = 1;
stagedActionIds = [0]; stagedActionIds = [0];
skippedActionIds = []; skippedActionIds = [];
@ -724,7 +742,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
case ActionTypes.IMPORT_STATE: { case ActionTypes.IMPORT_STATE: {
if (isArray(liftedAction.nextLiftedState)) { if (isArray(liftedAction.nextLiftedState)) {
// recompute array of actions // recompute array of actions
actionsById = { 0: liftAction<A>(INIT_ACTION as A) }; actionsById = { 0: liftAction(INIT_ACTION as A) };
nextActionId = 1; nextActionId = 1;
stagedActionIds = [0]; stagedActionIds = [0];
skippedActionIds = []; skippedActionIds = [];
@ -772,7 +790,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
return computePausedAction(true); return computePausedAction(true);
} }
// Commit when unpausing // Commit when unpausing
actionsById = { 0: liftAction<A>(INIT_ACTION as A) }; actionsById = { 0: liftAction(INIT_ACTION as A) };
nextActionId = 1; nextActionId = 1;
stagedActionIds = [0]; stagedActionIds = [0];
skippedActionIds = []; skippedActionIds = [];
@ -800,7 +818,7 @@ export function liftReducerWith<S, A extends Action<unknown>>(
skippedActionIds, skippedActionIds,
options.shouldCatchErrors options.shouldCatchErrors
); );
monitorState = monitorReducer(monitorState, liftedAction); monitorState = monitorReducer(monitorState, liftedAction as MonitorAction);
return { return {
monitorState, monitorState,
actionsById, actionsById,
@ -819,25 +837,55 @@ export function liftReducerWith<S, A extends Action<unknown>>(
/** /**
* Provides an app's view into the state of the lifted store. * Provides an app's view into the state of the lifted store.
*/ */
export function unliftState<S, A extends Action<unknown>, NextStateExt>( export function unliftState<
liftedState: LiftedState<S, A> & NextStateExt S,
) { A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>,
NextStateExt
>(
liftedState: LiftedState<S, A, MonitorState> & NextStateExt
): S & NextStateExt {
const { computedStates, currentStateIndex } = liftedState; const { computedStates, currentStateIndex } = liftedState;
const { state } = computedStates[currentStateIndex]; const { state } = computedStates[currentStateIndex];
return state; return state as S & NextStateExt;
} }
export type LiftedStore<S, A extends Action<unknown>> = Store< export type LiftedReducer<
LiftedState<S, A>, S,
LiftedAction<S, A> A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
> = Reducer<
LiftedState<S, A, MonitorState>,
LiftedAction<S, A, MonitorState, MonitorAction>
>; >;
export type InstrumentExt<S, A extends Action<unknown>> = { export type LiftedStore<
liftedStore: LiftedStore<S, A>; S,
A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
> = Store<
LiftedState<S, A, MonitorState>,
LiftedAction<S, A, MonitorState, MonitorAction>
>;
export type InstrumentExt<
S,
A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
> = {
liftedStore: LiftedStore<S, A, MonitorState, MonitorAction>;
}; };
export type EnhancedStore<S, A extends Action<unknown>> = Store<S, A> & export type EnhancedStore<
InstrumentExt<S, A>; S,
A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
> = Store<S, A> & InstrumentExt<S, A, MonitorState, MonitorAction>;
/** /**
* Provides an app's view into the lifted store. * Provides an app's view into the lifted store.
@ -845,26 +893,35 @@ export type EnhancedStore<S, A extends Action<unknown>> = Store<S, A> &
export function unliftStore< export function unliftStore<
S, S,
A extends Action<unknown>, A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>,
NextExt, NextExt,
NextStateExt NextStateExt
>( >(
liftedStore: Store<LiftedState<S, A> & NextStateExt, LiftedAction<S, A>> & liftedStore: Store<
LiftedState<S, A, MonitorState> & NextStateExt,
LiftedAction<S, A, MonitorState, MonitorAction>
> &
NextExt, NextExt,
liftReducer: ( liftReducer: (
r: Reducer<S, A> r: Reducer<S, A>
) => Reducer<LiftedState<S, A>, LiftedAction<S, A>>, ) => LiftedReducer<S, A, MonitorState, MonitorAction>,
options: Options<S, A> options: Options<S, A, MonitorState, MonitorAction>
): Store<S & NextStateExt, A> & ): Store<S & NextStateExt, A> &
NextExt & { NextExt & {
liftedStore: Store<LiftedState<S, A> & NextStateExt, LiftedAction<S, A>>; liftedStore: Store<
LiftedState<S, A, MonitorState> & NextStateExt,
LiftedAction<S, A, MonitorState, MonitorAction>
>;
} { } {
let lastDefinedState: S & NextStateExt; let lastDefinedState: S & NextStateExt;
const trace = options.trace || options.shouldIncludeCallstack; const trace = options.trace || options.shouldIncludeCallstack;
const traceLimit = options.traceLimit || 10; const traceLimit = options.traceLimit || 10;
function getState(): S & NextStateExt { function getState(): S & NextStateExt {
const state = unliftState<S, A, NextStateExt>(liftedStore.getState()) as S & const state = unliftState<S, A, MonitorState, MonitorAction, NextStateExt>(
NextStateExt; liftedStore.getState()
);
if (state !== undefined) { if (state !== undefined) {
lastDefinedState = state; lastDefinedState = state;
} }
@ -890,8 +947,8 @@ export function unliftStore<
(liftReducer( (liftReducer(
(nextReducer as unknown) as Reducer<S, A> (nextReducer as unknown) as Reducer<S, A>
) as unknown) as Reducer< ) as unknown) as Reducer<
LiftedState<S, A> & NextStateExt, LiftedState<S, A, MonitorState> & NextStateExt,
LiftedAction<S, A> LiftedAction<S, A, MonitorState, MonitorAction>
> >
); );
}, },
@ -922,16 +979,24 @@ export function unliftStore<
} }
} as unknown) as Store<S & NextStateExt, A> & } as unknown) as Store<S & NextStateExt, A> &
NextExt & { NextExt & {
liftedStore: Store<LiftedState<S, A> & NextStateExt, LiftedAction<S, A>>; liftedStore: Store<
LiftedState<S, A, MonitorState> & NextStateExt,
LiftedAction<S, A, MonitorState, MonitorAction>
>;
}; };
} }
export interface Options<S, A extends Action<unknown>> { export interface Options<
S,
A extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
> {
maxAge?: maxAge?:
| number | number
| (( | ((
currentLiftedAction: LiftedAction<S, A>, currentLiftedAction: LiftedAction<S, A, MonitorState, MonitorAction>,
previousLiftedState: LiftedState<S, A> | undefined previousLiftedState: LiftedState<S, A, MonitorState> | undefined
) => number); ) => number);
shouldCatchErrors?: boolean; shouldCatchErrors?: boolean;
shouldRecordChanges?: boolean; shouldRecordChanges?: boolean;
@ -946,10 +1011,40 @@ export interface Options<S, A extends Action<unknown>> {
/** /**
* Redux instrumentation store enhancer. * Redux instrumentation store enhancer.
*/ */
export default function instrument<OptionsS, OptionsA extends Action<unknown>>( export default function instrument<
monitorReducer: Reducer<unknown, Action<unknown>> = () => null, no_options_state = never,
options: Options<OptionsS, OptionsA> = {} no_options_action = never,
): StoreEnhancer<InstrumentExt<any, any>> { no_monitor_state = null,
no_monitor_action = never
>(): StoreEnhancer<InstrumentExt<any, any, any, any>>;
export default function instrument<
OptionsS,
OptionsA extends Action<unknown>,
no_monitor_state = null,
no_monitor_action = never
>(
monitorReducer: undefined,
options: Options<OptionsS, OptionsA, any, any>
): StoreEnhancer<InstrumentExt<any, any, any, any>>;
export default function instrument<
OptionsS,
OptionsA extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
>(
monitorReducer: Reducer<MonitorState, MonitorAction>,
options: Options<OptionsS, OptionsA, MonitorState, MonitorAction>
): StoreEnhancer<InstrumentExt<any, any, MonitorState, MonitorAction>>;
export default function instrument<
OptionsS,
OptionsA extends Action<unknown>,
MonitorState,
MonitorAction extends Action<unknown>
>(
monitorReducer: Reducer<MonitorState, MonitorAction> = ((() =>
null) as unknown) as Reducer<MonitorState, MonitorAction>,
options: Options<OptionsS, OptionsA, MonitorState, MonitorAction> = {}
): StoreEnhancer<InstrumentExt<any, any, MonitorState, MonitorAction>> {
if (typeof options.maxAge === 'number' && options.maxAge < 2) { if (typeof options.maxAge === 'number' && options.maxAge < 2) {
throw new Error( throw new Error(
'DevTools.instrument({ maxAge }) option, if specified, ' + 'DevTools.instrument({ maxAge }) option, if specified, ' +
@ -975,22 +1070,25 @@ export default function instrument<OptionsS, OptionsA extends Action<unknown>>(
} }
throw new Error('Expected the reducer to be a function.'); throw new Error('Expected the reducer to be a function.');
} }
return liftReducerWith<S, A>( return liftReducerWith<S, A, MonitorState, MonitorAction>(
r, r,
initialState, initialState,
monitorReducer, monitorReducer,
(options as unknown) as Options<S, A> (options as unknown) as Options<S, A, MonitorState, MonitorAction>
); );
} }
const liftedStore = createStore(liftReducer(reducer)); const liftedStore = createStore(liftReducer(reducer));
if ( if (
(liftedStore as Store< (liftedStore as Store<
LiftedState<S, A> & NextStateExt, LiftedState<S, A, MonitorState> & NextStateExt,
LiftedAction<S, A> LiftedAction<S, A, MonitorState, MonitorAction>
> & > &
NextExt & { NextExt & {
liftedStore: Store<LiftedState<S, A>, LiftedAction<S, A>>; liftedStore: Store<
LiftedState<S, A, MonitorState>,
LiftedAction<S, A, MonitorState, MonitorAction>
>;
}).liftedStore }).liftedStore
) { ) {
throw new Error( throw new Error(
@ -999,10 +1097,17 @@ export default function instrument<OptionsS, OptionsA extends Action<unknown>>(
); );
} }
return unliftStore<S, A, NextExt, NextStateExt>( return unliftStore<
S,
A,
MonitorState,
MonitorAction,
NextExt,
NextStateExt
>(
liftedStore, liftedStore,
liftReducer, liftReducer,
(options as unknown) as Options<S, A> (options as unknown) as Options<S, A, MonitorState, MonitorAction>
); );
}; };
} }

View File

@ -90,8 +90,8 @@ function counterWithMultiply(state = 0, action: CounterWithMultiplyAction) {
} }
describe('instrument', () => { describe('instrument', () => {
let store: EnhancedStore<number, CounterAction>; let store: EnhancedStore<number, CounterAction, null, never>;
let liftedStore: LiftedStore<number, CounterAction>; let liftedStore: LiftedStore<number, CounterAction, null, never>;
beforeEach(() => { beforeEach(() => {
store = createStore(counter, instrument()); store = createStore(counter, instrument());
@ -534,8 +534,8 @@ describe('instrument', () => {
}); });
describe('maxAge option', () => { describe('maxAge option', () => {
let configuredStore: EnhancedStore<number, CounterAction>; let configuredStore: EnhancedStore<number, CounterAction, null, never>;
let configuredLiftedStore: LiftedStore<number, CounterAction>; let configuredLiftedStore: LiftedStore<number, CounterAction, null, never>;
beforeEach(() => { beforeEach(() => {
configuredStore = createStore( configuredStore = createStore(
@ -618,7 +618,9 @@ describe('instrument', () => {
); );
const liftedStoreWithAnotherBug = (liftedStoreWithBug as unknown) as LiftedStore< const liftedStoreWithAnotherBug = (liftedStoreWithBug as unknown) as LiftedStore<
number, number,
CounterWithAnotherBugAction CounterWithAnotherBugAction,
null,
never
>; >;
expect(liftedStoreWithAnotherBug.getState().stagedActionIds).toHaveLength( expect(liftedStoreWithAnotherBug.getState().stagedActionIds).toHaveLength(
5 5
@ -630,7 +632,9 @@ describe('instrument', () => {
); );
const liftedStore = liftedStoreWithBug as LiftedStore< const liftedStore = liftedStoreWithBug as LiftedStore<
number, number,
CounterAction CounterAction,
null,
never
>; >;
expect(liftedStore.getState().stagedActionIds).toHaveLength(3); expect(liftedStore.getState().stagedActionIds).toHaveLength(3);
@ -698,7 +702,9 @@ describe('instrument', () => {
); );
const liftedStore = liftedStoreWithBug as LiftedStore< const liftedStore = liftedStoreWithBug as LiftedStore<
number, number,
CounterAction CounterAction,
null,
never
>; >;
const liftedStoreState = liftedStore.getState(); const liftedStoreState = liftedStore.getState();
const currentComputedState = const currentComputedState =
@ -730,7 +736,9 @@ describe('instrument', () => {
); );
const liftedStore = liftedStoreWithBug as LiftedStore< const liftedStore = liftedStoreWithBug as LiftedStore<
number, number,
CounterAction CounterAction,
null,
never
>; >;
const liftedStoreState = liftedStore.getState(); const liftedStoreState = liftedStore.getState();
const currentComputedState = const currentComputedState =
@ -1081,9 +1089,9 @@ describe('instrument', () => {
}); });
describe('Import State', () => { describe('Import State', () => {
let monitoredStore: EnhancedStore<number, CounterAction>; let monitoredStore: EnhancedStore<number, CounterAction, null, never>;
let monitoredLiftedStore: LiftedStore<number, CounterAction>; let monitoredLiftedStore: LiftedStore<number, CounterAction, null, never>;
let exportedState: LiftedState<number, CounterAction>; let exportedState: LiftedState<number, CounterAction, null>;
beforeEach(() => { beforeEach(() => {
monitoredStore = createStore(counter, instrument()); monitoredStore = createStore(counter, instrument());
@ -1164,7 +1172,7 @@ describe('instrument', () => {
}); });
function filterStackAndTimestamps<S, A extends Action<unknown>>( function filterStackAndTimestamps<S, A extends Action<unknown>>(
state: LiftedState<S, A> state: LiftedState<S, A, null>
) { ) {
state.actionsById = _.mapValues(state.actionsById, action => { state.actionsById = _.mapValues(state.actionsById, action => {
delete action.timestamp; delete action.timestamp;
@ -1175,9 +1183,9 @@ describe('instrument', () => {
} }
describe('Import Actions', () => { describe('Import Actions', () => {
let monitoredStore: EnhancedStore<number, CounterAction>; let monitoredStore: EnhancedStore<number, CounterAction, null, never>;
let monitoredLiftedStore: LiftedStore<number, CounterAction>; let monitoredLiftedStore: LiftedStore<number, CounterAction, null, never>;
let exportedState: LiftedState<number, CounterAction>; let exportedState: LiftedState<number, CounterAction, null>;
const savedActions = [ const savedActions = [
{ type: 'INCREMENT' }, { type: 'INCREMENT' },
{ type: 'INCREMENT' }, { type: 'INCREMENT' },
@ -1285,7 +1293,7 @@ describe('instrument', () => {
{ type: 'INCREMENT' } { type: 'INCREMENT' }
] as const; ] as const;
store.liftedStore.dispatch( store.liftedStore.dispatch(
ActionCreators.importState<number, CounterAction>(savedActions) ActionCreators.importState<number, CounterAction, null>(savedActions)
); );
expect(store.liftedStore.getState().nextActionId).toBe(3); expect(store.liftedStore.getState().nextActionId).toBe(3);
expect(store.getState()).toBe(2); expect(store.getState()).toBe(2);