mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 08:30:02 +03:00
fix(compose): generic types
This commit is contained in:
parent
07ac78f26d
commit
05eed818ae
|
@ -600,8 +600,8 @@ const extensionCompose =
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ReduxDevtoolsExtensionCompose {
|
interface ReduxDevtoolsExtensionCompose {
|
||||||
(config: Config): (...funcs: StoreEnhancer[]) => StoreEnhancer;
|
(config: Config): <StoreExt>(...funcs: Array<StoreEnhancer<StoreExt>>) => StoreEnhancer<StoreExt>;
|
||||||
(...funcs: StoreEnhancer[]): StoreEnhancer;
|
<StoreExt>(...funcs: Array<StoreEnhancer<StoreExt>>): StoreEnhancer<StoreExt>;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -610,20 +610,20 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reduxDevtoolsExtensionCompose(
|
function reduxDevtoolsExtensionCompose<StoreExt>(
|
||||||
config: Config
|
config: Config
|
||||||
): (...funcs: StoreEnhancer[]) => StoreEnhancer;
|
): (...funcs: Array<StoreEnhancer<StoreExt>>) => StoreEnhancer<StoreExt>;
|
||||||
function reduxDevtoolsExtensionCompose(
|
function reduxDevtoolsExtensionCompose<StoreExt>(
|
||||||
...funcs: StoreEnhancer[]
|
...funcs: Array<StoreEnhancer<StoreExt>>
|
||||||
): StoreEnhancer;
|
): StoreEnhancer<StoreExt>;
|
||||||
function reduxDevtoolsExtensionCompose(...funcs: [Config] | StoreEnhancer[]) {
|
function reduxDevtoolsExtensionCompose<StoreExt>(...funcs: [Config] | Array<StoreEnhancer<StoreExt>>) {
|
||||||
if (funcs.length === 0) {
|
if (funcs.length === 0) {
|
||||||
return __REDUX_DEVTOOLS_EXTENSION__();
|
return __REDUX_DEVTOOLS_EXTENSION__();
|
||||||
}
|
}
|
||||||
if (funcs.length === 1 && typeof funcs[0] === 'object') {
|
if (funcs.length === 1 && typeof funcs[0] === 'object') {
|
||||||
return extensionCompose(funcs[0]);
|
return extensionCompose(funcs[0]);
|
||||||
}
|
}
|
||||||
return extensionCompose({})(...(funcs as StoreEnhancer[]));
|
return extensionCompose({})(...(funcs as Array<StoreEnhancer<StoreExt>>));
|
||||||
}
|
}
|
||||||
|
|
||||||
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = reduxDevtoolsExtensionCompose;
|
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ = reduxDevtoolsExtensionCompose;
|
||||||
|
|
|
@ -195,8 +195,8 @@ interface ReduxDevtoolsExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReduxDevtoolsExtensionCompose {
|
export interface ReduxDevtoolsExtensionCompose {
|
||||||
(config: Config): (...funcs: StoreEnhancer[]) => StoreEnhancer;
|
(config: Config): <StoreExt>(...funcs: Array<StoreEnhancer<StoreExt>>) => StoreEnhancer<StoreExt>;
|
||||||
(...funcs: StoreEnhancer[]): StoreEnhancer;
|
<StoreExt>(...funcs: Array<StoreEnhancer<StoreExt>>): StoreEnhancer<StoreExt>;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -206,14 +206,14 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function extensionComposeStub(
|
function extensionComposeStub<StoreExt>(
|
||||||
config: Config
|
config: Config
|
||||||
): (...funcs: StoreEnhancer[]) => StoreEnhancer;
|
): (...funcs: Array<StoreEnhancer<StoreExt>>) => StoreEnhancer<StoreExt>;
|
||||||
function extensionComposeStub(...funcs: StoreEnhancer[]): StoreEnhancer;
|
function extensionComposeStub<StoreExt>(...funcs: Array<StoreEnhancer<StoreExt>>): StoreEnhancer<StoreExt>;
|
||||||
function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) {
|
function extensionComposeStub<StoreExt>(...funcs: [Config] | Array<StoreEnhancer<StoreExt>>) {
|
||||||
if (funcs.length === 0) return undefined;
|
if (funcs.length === 0) return undefined;
|
||||||
if (typeof funcs[0] === 'object') return compose;
|
if (typeof funcs[0] === 'object') return compose;
|
||||||
return compose(...(funcs as StoreEnhancer[]));
|
return compose(...(funcs as Array<StoreEnhancer<StoreExt>>));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
export const composeWithDevTools: ReduxDevtoolsExtensionCompose =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user