diff --git a/app/core/EngineService/EngineService.ts b/app/core/EngineService/EngineService.ts index 485f8689948..233e05599c8 100644 --- a/app/core/EngineService/EngineService.ts +++ b/app/core/EngineService/EngineService.ts @@ -1,7 +1,7 @@ import UntypedEngine from '../Engine'; import { Engine as TypedEngine } from '../Engine/Engine'; import { getVaultFromBackup } from '../BackupVault'; -import { store as importedStore } from '../../store'; +import { store as importedStore, ReduxStore } from '../../store'; import Logger from '../../util/Logger'; import { NO_VAULT_IN_BACKUP_ERROR, @@ -28,9 +28,7 @@ class EngineService { * @param store - Redux store */ - // TODO: Replace "any" with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - initalizeEngine = (store: any) => { + initalizeEngine = (store: ReduxStore) => { trace({ name: TraceName.EngineInitialization, op: TraceOperation.EngineInitialization, @@ -46,9 +44,7 @@ class EngineService { endTrace({ name: TraceName.EngineInitialization }); }; - // TODO: Replace "any" with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - private updateControllers = (store: any, engine: TypedEngine) => { + private updateControllers = (store: ReduxStore, engine: TypedEngine) => { if (!engine.context) { Logger.error( new Error( diff --git a/app/store/index.ts b/app/store/index.ts index 01200a0261f..899e9015337 100644 --- a/app/store/index.ts +++ b/app/store/index.ts @@ -1,4 +1,4 @@ -import { Store } from 'redux'; +import { AnyAction } from 'redux'; import { configureStore } from '@reduxjs/toolkit'; import { persistStore, persistReducer } from 'redux-persist'; import createSagaMiddleware from 'redux-saga'; @@ -16,17 +16,15 @@ import thunk from 'redux-thunk'; import persistConfig from './persistConfig'; import { AppStateEventProcessor } from '../core/AppStateEventListener'; import getUIStartupSpan from '../core/Performance/UIStartup'; +import { ToolkitStore } from '@reduxjs/toolkit/dist/configureStore'; // TODO: Improve type safety by using real Action types instead of `any` -// TODO: Replace "any" with type -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const pReducer = persistReducer(persistConfig, rootReducer); +const pReducer = persistReducer(persistConfig, rootReducer); // TODO: Fix the Action type. It's set to `any` now because some of the // TypeScript reducers have invalid actions -// TODO: Replace "any" with type -// eslint-disable-next-line @typescript-eslint/no-explicit-any, import/no-mutable-exports -let store: Store, persistor; +// eslint-disable-next-line import/no-mutable-exports +let store: ReduxStore, persistor; const createStoreAndPersistor = async () => { trace({ name: TraceName.StoreInit, @@ -109,3 +107,9 @@ const createStoreAndPersistor = async () => { })(); export { store, persistor }; + +export type ReduxStore = ToolkitStore< + ReturnType, + AnyAction, + [ReturnType>, typeof thunk] +>;