Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript issue along with Redux 4.0.5 #3742

Closed
saikats5 opened this issue Apr 7, 2020 · 2 comments
Closed

Typescript issue along with Redux 4.0.5 #3742

saikats5 opened this issue Apr 7, 2020 · 2 comments

Comments

@saikats5
Copy link

saikats5 commented Apr 7, 2020

I am getting below errors after upgrading to redux 4.0.5

app/store/reducer.ts:58:7 - error TS2345: Argument of type 'AnyAction' is not assignable to parameter of type 'never'.

58 action
~~~~~~

app/store/reducer.ts:62:18 - error TS2345: Argument of type 'StateRoot' is not assignable to parameter of type 'CombinedState<{ [x: string]: unknown; }>'.
Type 'StateRoot' is not assignable to type '{ [x: string]: unknown; }'.
Index signature is missing in type 'StateRoot'.

62 return reducer(state, action)
~~~~~

Found 2 errors.

@timdorr
Copy link
Member

timdorr commented Apr 7, 2020

Without any code examples, I can't tell what's going on here. But I would look at the discussion in #3484 where this was changed.

@timdorr timdorr closed this as completed Apr 7, 2020
@saikats5
Copy link
Author

saikats5 commented Apr 7, 2020

Please find below the code

import { applyMiddleware, createStore, Store } from 'redux'
import { createEpicMiddleware } from 'redux-observable'
import { Persistor, persistReducer, persistStore } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import { composeWithDevTools } from 'remote-redux-devtools'


export class StoreServices {
  public persistor: Persistor
  public currentStore: Store<ReduxState>

  constructor() {
    const epicMiddleware = createEpicMiddleware(rootEpic, {
      dependencies: epicDependencies
    })

    const persistConfig: any = {
      key: 'root',
      storage,
      whitelist: ['mobileContent']
    }

    const persistedReducer = persistReducer<any, any>(persistConfig, reducer)
    const composeEnhancers = composeWithDevTools({ realtime: EnvironmentSelector.currentEnv, hostname: 'localhost', port: 8080 })
    const store = createStore<any, any, any, any>(
      persistedReducer,
      composeEnhancers(applyMiddleware(epicMiddleware))
    )

    this.currentStore = store
    this.persistor = persistStore(store)
    epicMiddleware.replaceEpic(rootEpic)
  }
}

@reduxjs reduxjs deleted a comment from saikats5 Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants