Skip to content

Typescript definition does not allow for enhancer composition #2130

Closed
@santiagoaguiar

Description

@santiagoaguiar

What is the current behavior?

export type StoreEnhancerStoreCreator<S> = (reducer: Reducer<S>, preloadedState?: S, enhancer?: StoreEnhancer<S>) => Store<S>;

Does not allow an enhancer argument, therefore the

This doesn't let you create a enhancer like https://github.com/reactjs/redux/blob/master/src/applyMiddleware.js with typescript, since you can't chain the enhancers.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar.

import * as Redux from "redux";
interface State {}
export const enhancer: Redux.StoreEnhancer<State> = createStore => (reducer, preloadedState, enhancer?) => {
    return createStore(reducer, preloadedState, enhancer) ;
}

Does not compile.

What is the expected behavior?
Should compile.

Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?
3.6.0

Given #1648 I may be missing something, but I think changing it to

export type StoreEnhancerStoreCreator<S> = (reducer: Reducer<S>, preloadedState?: S, enhancer?: StoreEnhancer<S>) => Store<S>;`

would be enough until that issue is resolved.

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