Skip to content

Extra properties added to store by enhancers are not getting inferred by configureStore #699

Closed
@stefan-wullems

Description

@stefan-wullems

I have a custom enhancer with the following signature:

export interface ExtraProperties<PS> {
  persistence: {
    getPersistentState: () => PS
    hydrate: (state: PS) => void
    flush: () => void
  }
}


 
const enhancer = (createStore: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator<ExtraProperties<PS>> => {
  return <S = any, A extends Action = AnyAction>(
    reducer: Reducer<S, A>,
    preloadedState?: PreloadedState<S>
  ) => {
   ...
  }
}

However when I add this enhancer to configureStore, the type of the returned store doesn't change at all.

image

This is caused by the fact that configureStore has type parameters for the state, actions and middleware, but not for the enhancer.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions