angular-redux / store

Angular 2+ bindings for Redux
MIT License
1.34k stars 205 forks source link

Compile error due to interface mismatch on NgRedux and Dispatch<Action> type #520

Closed stochris closed 6 years ago

stochris commented 6 years ago

This is a...

What toolchain are you using for transpilation/bundling?

Environment

NodeJS Version:v8.11.1 Typescript Version:2.8.1 Angular Version: 5.2.0 @angular-redux/store version: ^7.1.1 @angular/cli version: (if applicable) 1.7.4 OS: macOS High Sierra 10.13.4

Link to repo showing the issus

(optional, but helps a lot) https://github.com/stochris/angular-redux-repro

Expected Behaviour:

The type checks should work

Actual Behaviour:

When serving the app, the type checks ( and the whole build ) fails.

Stack Trace/Error Message:

ERROR in node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts(10,31): error TS2420: Class 'NgRedux<RootState>' incorrectly implements interface 'ObservableStore<RootState>'.
  Types of property 'dispatch' are incompatible.
    Type 'Dispatch<RootState>' is not assignable to type 'Dispatch<AnyAction>'.
      Type 'RootState' is not assignable to type 'AnyAction'.
node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts(37,33): error TS2344: Type 'RootState' does not satisfy the constraint 'Action<any>'.
node_modules/@angular-redux/store/lib/src/components/root-store.d.ts(18,24): error TS2344: Type 'RootState' does not satisfy the constraint 'Action<any>'.

Additional Notes:

(optional)

This is a new project, created with the latest versions of everything.

Also, I checked the typings, and it seems the dispatch property on the NgRedux class uses the RootState template argument, instead of a generic action

stochris commented 6 years ago

Never mind, I didn't watch for the peerDeps warnings about redux. Thanks a lot

tobzy commented 6 years ago

I have the exact same issue.

stochris commented 6 years ago

You need redux v3, not 4