diff --git a/packages/redux-devtools-extension/src/developmentOnly.ts b/packages/redux-devtools-extension/src/developmentOnly.ts index 61c9502f..4fec0ed1 100644 --- a/packages/redux-devtools-extension/src/developmentOnly.ts +++ b/packages/redux-devtools-extension/src/developmentOnly.ts @@ -15,18 +15,16 @@ declare const process: { function extensionComposeStub( config: Config, -): []>( +): ( ...funcs: StoreEnhancers ) => StoreEnhancer>; -function extensionComposeStub< - StoreEnhancers extends readonly StoreEnhancer[], ->( +function extensionComposeStub( ...funcs: StoreEnhancers ): StoreEnhancer>; -function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) { +function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) { if (funcs.length === 0) return undefined; if (typeof funcs[0] === 'object') return compose; - return compose(...(funcs as StoreEnhancer[])); + return compose(...(funcs as StoreEnhancer[])); } export const composeWithDevTools: ReduxDevtoolsExtensionCompose = diff --git a/packages/redux-devtools-extension/src/index.ts b/packages/redux-devtools-extension/src/index.ts index 86293b55..366b9e21 100644 --- a/packages/redux-devtools-extension/src/index.ts +++ b/packages/redux-devtools-extension/src/index.ts @@ -235,15 +235,16 @@ export type InferComposedStoreExt = StoreEnhancers extends [ ? HeadStoreEnhancer extends StoreEnhancer ? StoreExt & InferComposedStoreExt : never - : unknown; + : // eslint-disable-next-line @typescript-eslint/no-empty-object-type + {}; export interface ReduxDevtoolsExtensionCompose { ( config: Config, - ): []>( + ): ( ...funcs: StoreEnhancers ) => StoreEnhancer>; - []>( + ( ...funcs: StoreEnhancers ): StoreEnhancer>; } @@ -257,18 +258,16 @@ declare global { function extensionComposeStub( config: Config, -): []>( +): ( ...funcs: StoreEnhancers ) => StoreEnhancer>; -function extensionComposeStub< - StoreEnhancers extends readonly StoreEnhancer[], ->( +function extensionComposeStub( ...funcs: StoreEnhancers ): StoreEnhancer>; -function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) { +function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) { if (funcs.length === 0) return undefined; if (typeof funcs[0] === 'object') return compose; - return compose(...(funcs as StoreEnhancer[])); + return compose(...(funcs as StoreEnhancer[])); } export const composeWithDevTools: ReduxDevtoolsExtensionCompose = diff --git a/packages/redux-devtools-extension/src/logOnly.ts b/packages/redux-devtools-extension/src/logOnly.ts index 67b54382..349ed720 100644 --- a/packages/redux-devtools-extension/src/logOnly.ts +++ b/packages/redux-devtools-extension/src/logOnly.ts @@ -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 >( - reducer: Reducer, - preloadedState: PreloadedState | undefined, + return function , PreloadedState>( + reducer: Reducer, + 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[]) { + return function (...funcs: StoreEnhancer[]) { return compose(compose(...funcs), enhancer(config)); }; } export function composeWithDevTools( config: Config, -): []>( +): ( ...funcs: StoreEnhancers ) => StoreEnhancer>; export function composeWithDevTools< - StoreEnhancers extends readonly StoreEnhancer[], + StoreEnhancers extends readonly StoreEnhancer[], >( ...funcs: StoreEnhancers ): StoreEnhancer>; -export function composeWithDevTools( - ...funcs: [Config] | StoreEnhancer[] -) { +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[])); + return composeWithEnhancer()(...(funcs as StoreEnhancer[])); } if (funcs.length === 0) return undefined; diff --git a/packages/redux-devtools-extension/src/logOnlyInProduction.ts b/packages/redux-devtools-extension/src/logOnlyInProduction.ts index 59ccf317..cdc06c55 100644 --- a/packages/redux-devtools-extension/src/logOnlyInProduction.ts +++ b/packages/redux-devtools-extension/src/logOnlyInProduction.ts @@ -16,18 +16,16 @@ declare const process: { function extensionComposeStub( config: Config, -): []>( +): ( ...funcs: StoreEnhancers ) => StoreEnhancer>; -function extensionComposeStub< - StoreEnhancers extends readonly StoreEnhancer[], ->( +function extensionComposeStub( ...funcs: StoreEnhancers ): StoreEnhancer>; -function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) { +function extensionComposeStub(...funcs: [Config] | StoreEnhancer[]) { if (funcs.length === 0) return undefined; if (typeof funcs[0] === 'object') return compose; - return compose(...(funcs as StoreEnhancer[])); + return compose(...(funcs as StoreEnhancer[])); } export const composeWithDevTools: ReduxDevtoolsExtensionCompose = diff --git a/packages/redux-devtools-extension/src/utils/assign.ts b/packages/redux-devtools-extension/src/utils/assign.ts deleted file mode 100644 index b453fb6e..00000000 --- a/packages/redux-devtools-extension/src/utils/assign.ts +++ /dev/null @@ -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( - 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; -}