Skip to content

Error in types for middleware (typescript 2.4.1) #2481

Closed
@artem-malko

Description

@artem-malko

It is a bug

I have this simple middleware:

import { Middleware, Store, Dispatch, Action } from 'redux';
import { AppState } from 'types/appState';

export default function createSimpleMiddleware(): Middleware {
  return (store: Store<AppState>) => (next: Dispatch<AppState>) => (action: Action): Action => {
    return next(action);
  };
}

It is useless, but there is a problem) This code works with typescript version 2.3.x and below. But in typescript 2.4 there is an Error.

What is the current behavior?
In typescript I have this Error:

Types of parameters 'store' and 'api' are incompatible.
    Type 'MiddlewareAPI<S>' is not assignable to type 'Store<AppState>'.

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.

You can find demo code at the top of current issue.

What is the expected behavior?

I expect, that there won't be any errors.

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

Typescript: 2.4.1
Redux: 3.7.1
NodeJS: 6.9.1
OS: MacOS

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