Skip to content

Commit

Permalink
Define type ReduxStore
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorLift committed Dec 2, 2024
1 parent ea449c7 commit 3ade7e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 3 additions & 7 deletions app/core/EngineService/EngineService.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand Down
18 changes: 11 additions & 7 deletions app/store/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<RootState, any>(persistConfig, rootReducer);
const pReducer = persistReducer<RootState, AnyAction>(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<RootState, any>, persistor;
// eslint-disable-next-line import/no-mutable-exports
let store: ReduxStore, persistor;
const createStoreAndPersistor = async () => {
trace({
name: TraceName.StoreInit,
Expand Down Expand Up @@ -109,3 +107,9 @@ const createStoreAndPersistor = async () => {
})();

export { store, persistor };

export type ReduxStore = ToolkitStore<
ReturnType<typeof pReducer>,
AnyAction,
[ReturnType<typeof createSagaMiddleware<typeof rootSaga>>, typeof thunk]
>;

0 comments on commit 3ade7e5

Please sign in to comment.