mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 00:19:55 +03:00
Fix instrument build
This commit is contained in:
parent
a5957ed194
commit
b630e5c7e9
|
@ -4,7 +4,6 @@ import isPlainObject from 'lodash/isPlainObject';
|
|||
import {
|
||||
Action,
|
||||
Observer,
|
||||
PreloadedState,
|
||||
Reducer,
|
||||
Store,
|
||||
StoreEnhancer,
|
||||
|
@ -271,8 +270,8 @@ export const INIT_ACTION = { type: '@@INIT' };
|
|||
/**
|
||||
* Computes the next entry with exceptions catching.
|
||||
*/
|
||||
function computeWithTryCatch<S, A extends Action<string>>(
|
||||
reducer: Reducer<S, A>,
|
||||
function computeWithTryCatch<S, A extends Action<string>, PreloadedState>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
action: A,
|
||||
state: S,
|
||||
) {
|
||||
|
@ -301,8 +300,8 @@ function computeWithTryCatch<S, A extends Action<string>>(
|
|||
/**
|
||||
* Computes the next entry in the log by applying an action.
|
||||
*/
|
||||
function computeNextEntry<S, A extends Action<string>>(
|
||||
reducer: Reducer<S, A>,
|
||||
function computeNextEntry<S, A extends Action<string>, PreloadedState>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
action: A,
|
||||
state: S,
|
||||
shouldCatchErrors: boolean | undefined,
|
||||
|
@ -316,10 +315,10 @@ function computeNextEntry<S, A extends Action<string>>(
|
|||
/**
|
||||
* Runs the reducer on invalidated actions to get a fresh computation log.
|
||||
*/
|
||||
function recomputeStates<S, A extends Action<string>>(
|
||||
function recomputeStates<S, A extends Action<string>, PreloadedState>(
|
||||
computedStates: { state: S; error?: string }[],
|
||||
minInvalidatedStateIndex: number,
|
||||
reducer: Reducer<S, A>,
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
committedState: S,
|
||||
actionsById: { [actionId: number]: PerformAction<A> },
|
||||
stagedActionIds: number[],
|
||||
|
@ -413,11 +412,12 @@ export interface LiftedState<S, A extends Action<string>, MonitorState> {
|
|||
function liftReducerWith<
|
||||
S,
|
||||
A extends Action<string>,
|
||||
PreloadedState,
|
||||
MonitorState,
|
||||
MonitorAction extends Action<string>,
|
||||
>(
|
||||
reducer: Reducer<S, A>,
|
||||
initialCommittedState: PreloadedState<S> | undefined,
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
initialCommittedState: S | PreloadedState | undefined,
|
||||
monitorReducer: Reducer<MonitorState, MonitorAction>,
|
||||
options: Options<S, A, MonitorState, MonitorAction>,
|
||||
): Reducer<LiftedState<S, A, MonitorState>, LiftedAction<S, A, MonitorState>> {
|
||||
|
@ -575,7 +575,7 @@ function liftReducerWith<
|
|||
|
||||
if (maxAge && stagedActionIds.length > maxAge) {
|
||||
// States must be recomputed before committing excess.
|
||||
computedStates = recomputeStates<S, A>(
|
||||
computedStates = recomputeStates<S, A, PreloadedState>(
|
||||
computedStates,
|
||||
minInvalidatedStateIndex,
|
||||
reducer,
|
||||
|
@ -872,6 +872,7 @@ export type EnhancedStore<S, A extends Action<string>, MonitorState> = Store<
|
|||
function unliftStore<
|
||||
S,
|
||||
A extends Action<string>,
|
||||
PreloadedState,
|
||||
MonitorState,
|
||||
MonitorAction extends Action<string>,
|
||||
NextExt,
|
||||
|
@ -882,7 +883,9 @@ function unliftStore<
|
|||
LiftedAction<S, A, MonitorState>
|
||||
> &
|
||||
NextExt,
|
||||
liftReducer: (r: Reducer<S, A>) => LiftedReducer<S, A, MonitorState>,
|
||||
liftReducer: (
|
||||
r: Reducer<S, A, PreloadedState>,
|
||||
) => LiftedReducer<S, A, MonitorState>,
|
||||
options: Options<S, A, MonitorState, MonitorAction>,
|
||||
) {
|
||||
let lastDefinedState: S & NextStateExt;
|
||||
|
@ -924,7 +927,7 @@ function unliftStore<
|
|||
replaceReducer(nextReducer: Reducer<S & NextStateExt, A>) {
|
||||
liftedStore.replaceReducer(
|
||||
liftReducer(
|
||||
nextReducer as unknown as Reducer<S, A>,
|
||||
nextReducer as unknown as Reducer<S, A, PreloadedState>,
|
||||
) as unknown as Reducer<
|
||||
LiftedState<S, A, MonitorState> & NextStateExt,
|
||||
LiftedAction<S, A, MonitorState>
|
||||
|
@ -1006,14 +1009,17 @@ export function instrument<
|
|||
);
|
||||
}
|
||||
|
||||
return <NextExt, NextStateExt>(
|
||||
return <
|
||||
NextExt extends NonNullable<unknown>,
|
||||
NextStateExt extends NonNullable<unknown>,
|
||||
>(
|
||||
createStore: StoreEnhancerStoreCreator<NextExt, NextStateExt>,
|
||||
) =>
|
||||
<S, A extends Action<string>>(
|
||||
reducer: Reducer<S, A>,
|
||||
initialState?: PreloadedState<S>,
|
||||
<S, A extends Action<string>, PreloadedState>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
initialState?: PreloadedState | undefined,
|
||||
) => {
|
||||
function liftReducer(r: Reducer<S, A>) {
|
||||
function liftReducer(r: Reducer<S, A, PreloadedState>) {
|
||||
if (typeof r !== 'function') {
|
||||
if (r && typeof (r as { default: unknown }).default === 'function') {
|
||||
throw new Error(
|
||||
|
@ -1025,7 +1031,13 @@ export function instrument<
|
|||
}
|
||||
throw new Error('Expected the reducer to be a function.');
|
||||
}
|
||||
return liftReducerWith<S, A, MonitorState, MonitorAction>(
|
||||
return liftReducerWith<
|
||||
S,
|
||||
A,
|
||||
PreloadedState,
|
||||
MonitorState,
|
||||
MonitorAction
|
||||
>(
|
||||
r,
|
||||
initialState,
|
||||
monitorReducer,
|
||||
|
@ -1057,12 +1069,17 @@ export function instrument<
|
|||
return unliftStore<
|
||||
S,
|
||||
A,
|
||||
PreloadedState,
|
||||
MonitorState,
|
||||
MonitorAction,
|
||||
NextExt,
|
||||
NextStateExt
|
||||
>(
|
||||
liftedStore,
|
||||
liftedStore as Store<
|
||||
LiftedState<S, A, MonitorState> & NextStateExt,
|
||||
LiftedAction<S, A, MonitorState>
|
||||
> &
|
||||
NextExt,
|
||||
liftReducer,
|
||||
options as unknown as Options<S, A, MonitorState, MonitorAction>,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user