angular-redux / router

Keep your Angular2+ router state in Redux
MIT License
28 stars 7 forks source link

Support Typescript 2.4.x #17

Closed SethDavenport closed 7 years ago

SethDavenport commented 7 years ago

This is a...

What toolchain are you using for transpilation/bundling?

Environment

NodeJS Version: Typescript Version: Angular Version: @angular-redux/store version: @angular/cli version: (if applicable) OS:

Link to repo showing the issus

(optional, but helps a lot)

Expected Behaviour:

This should work fine (it does in typescript < 2.4)

import { routerReducer } from '@angular-redux/router';

export const rootReducer = composeReducers(
  combineReducers({
    // ... etc.
    router: routerReducer,
  }));

Actual Behaviour:

You get a TSC error (below).

Stack Trace/Error Message:

ERROR in /Users/sdavenport/code/angular-redux/example-app/src/app/store/reducers.ts (12,19): Argument of type '{ router: routerReducer...' is not assignable to parameter of type 'ReducersMapObject'.
  Property 'router' is incompatible with index signature.
    Type '(state: string, action: RouterAction) => string' is not assignable to type 'Reducer<any>'.
      Types of parameters 'action' and 'action' are incompatible.
        Type 'A' is not assignable to type 'RouterAction'.
          Type 'Action' is not assignable to type 'RouterAction'.
            Property 'payload' is missing in type 'Action'.

Additional Notes:

(optional)

SethDavenport commented 7 years ago

Typescript's stricter checks for higher order functions have exposed a bug in the Redux typings, discussion here: https://github.com/reactjs/redux/pull/2467

A fix has been merged to Redux but it's waiting for a new npm release. In the meantime we might be able to get away with a downcast in the implementation of routerReducer.

SethDavenport commented 7 years ago

Fixed in @angular-redux/router@6.3.1.