mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 08:30:02 +03:00
Fix redux-devtools-extension build
This commit is contained in:
parent
1b29f90cf2
commit
e2c1178667
|
@ -15,18 +15,16 @@ declare const process: {
|
|||
|
||||
function extensionComposeStub(
|
||||
config: Config,
|
||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
||||
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
function extensionComposeStub<
|
||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
||||
>(
|
||||
function extensionComposeStub<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer<unknown>[]) {
|
||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) {
|
||||
if (funcs.length === 0) return undefined;
|
||||
if (typeof funcs[0] === 'object') return compose;
|
||||
return compose(...(funcs as StoreEnhancer<unknown>[]));
|
||||
return compose(...(funcs as StoreEnhancer[]));
|
||||
}
|
||||
|
||||
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
||||
|
|
|
@ -235,15 +235,16 @@ export type InferComposedStoreExt<StoreEnhancers> = StoreEnhancers extends [
|
|||
? HeadStoreEnhancer extends StoreEnhancer<infer StoreExt>
|
||||
? StoreExt & InferComposedStoreExt<RestStoreEnhancers>
|
||||
: never
|
||||
: unknown;
|
||||
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
{};
|
||||
|
||||
export interface ReduxDevtoolsExtensionCompose {
|
||||
(
|
||||
config: Config,
|
||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
||||
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
<StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
||||
<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
}
|
||||
|
@ -257,18 +258,16 @@ declare global {
|
|||
|
||||
function extensionComposeStub(
|
||||
config: Config,
|
||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
||||
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
function extensionComposeStub<
|
||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
||||
>(
|
||||
function extensionComposeStub<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer<unknown>[]) {
|
||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) {
|
||||
if (funcs.length === 0) return undefined;
|
||||
if (typeof funcs[0] === 'object') return compose;
|
||||
return compose(...(funcs as StoreEnhancer<unknown>[]));
|
||||
return compose(...(funcs as StoreEnhancer[]));
|
||||
}
|
||||
|
||||
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
import assign from './utils/assign';
|
||||
import { compose } from 'redux';
|
||||
import type {
|
||||
Action,
|
||||
Dispatch,
|
||||
PreloadedState,
|
||||
Reducer,
|
||||
StoreEnhancer,
|
||||
} from 'redux';
|
||||
import type { Action, Dispatch, Reducer, StoreEnhancer } from 'redux';
|
||||
import type { Config, EnhancerOptions, InferComposedStoreExt } from './index';
|
||||
|
||||
function enhancer(options?: EnhancerOptions): StoreEnhancer {
|
||||
|
@ -17,9 +10,9 @@ function enhancer(options?: EnhancerOptions): StoreEnhancer {
|
|||
if (config.latency === undefined) config.latency = 500;
|
||||
|
||||
return function (createStore) {
|
||||
return function <S, A extends Action<string>>(
|
||||
reducer: Reducer<S, A>,
|
||||
preloadedState: PreloadedState<S> | undefined,
|
||||
return function <S, A extends Action<string>, PreloadedState>(
|
||||
reducer: Reducer<S, A, PreloadedState>,
|
||||
preloadedState?: PreloadedState | undefined,
|
||||
) {
|
||||
const store = createStore(reducer, preloadedState);
|
||||
const origDispatch = store.dispatch;
|
||||
|
@ -33,35 +26,32 @@ function enhancer(options?: EnhancerOptions): StoreEnhancer {
|
|||
return r;
|
||||
};
|
||||
|
||||
if (Object.assign) return Object.assign(store, { dispatch: dispatch });
|
||||
return assign(store, 'dispatch', dispatch);
|
||||
return Object.assign(store, { dispatch: dispatch });
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function composeWithEnhancer(config?: EnhancerOptions) {
|
||||
return function (...funcs: StoreEnhancer<unknown>[]) {
|
||||
return function (...funcs: StoreEnhancer[]) {
|
||||
return compose(compose(...funcs), enhancer(config));
|
||||
};
|
||||
}
|
||||
|
||||
export function composeWithDevTools(
|
||||
config: Config,
|
||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
||||
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
export function composeWithDevTools<
|
||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
||||
StoreEnhancers extends readonly StoreEnhancer[],
|
||||
>(
|
||||
...funcs: StoreEnhancers
|
||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
export function composeWithDevTools(
|
||||
...funcs: [Config] | StoreEnhancer<unknown>[]
|
||||
) {
|
||||
export function composeWithDevTools(...funcs: [Config] | StoreEnhancer[]) {
|
||||
if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
|
||||
if (funcs.length === 0) return enhancer();
|
||||
if (typeof funcs[0] === 'object') return composeWithEnhancer(funcs[0]);
|
||||
return composeWithEnhancer()(...(funcs as StoreEnhancer<unknown>[]));
|
||||
return composeWithEnhancer()(...(funcs as StoreEnhancer[]));
|
||||
}
|
||||
|
||||
if (funcs.length === 0) return undefined;
|
||||
|
|
|
@ -16,18 +16,16 @@ declare const process: {
|
|||
|
||||
function extensionComposeStub(
|
||||
config: Config,
|
||||
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
|
||||
): <StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
function extensionComposeStub<
|
||||
StoreEnhancers extends readonly StoreEnhancer<unknown>[],
|
||||
>(
|
||||
function extensionComposeStub<StoreEnhancers extends readonly StoreEnhancer[]>(
|
||||
...funcs: StoreEnhancers
|
||||
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
|
||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer<unknown>[]) {
|
||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) {
|
||||
if (funcs.length === 0) return undefined;
|
||||
if (typeof funcs[0] === 'object') return compose;
|
||||
return compose(...(funcs as StoreEnhancer<unknown>[]));
|
||||
return compose(...(funcs as StoreEnhancer[]));
|
||||
}
|
||||
|
||||
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
const objectKeys =
|
||||
Object.keys ||
|
||||
function (obj) {
|
||||
const keys = [];
|
||||
for (const key in obj) {
|
||||
if ({}.hasOwnProperty.call(obj, key)) keys.push(key);
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
|
||||
export default function assign<T extends object, K extends keyof T>(
|
||||
obj: T,
|
||||
newKey: K,
|
||||
newValue: T[K],
|
||||
): T {
|
||||
const keys = objectKeys(obj);
|
||||
const copy: T = {} as T;
|
||||
|
||||
for (let i = 0, l = keys.length; i < l; i++) {
|
||||
const key = keys[i];
|
||||
copy[key as keyof T] = obj[key as keyof T];
|
||||
}
|
||||
|
||||
copy[newKey] = newValue;
|
||||
return copy;
|
||||
}
|
Loading…
Reference in New Issue
Block a user