knpwrs / redux-ts-utils

Everything you need to create type-safe applications with Redux!
MIT License
55 stars 4 forks source link

Type error using redux-thunk #13

Closed camfletch closed 5 years ago

camfletch commented 5 years ago
import { ThunkAction } from 'redux-thunk';
import { createAction } from 'redux-ts-utils';

type State = {}

const someAction = createAction<void>('SOME_ACTION');

export const sampleThunk = (): ThunkAction<Promise<void>, State, void> => async (dispatch, getState) => {
  await Promise.resolve();
  dispatch(someAction());
};

Produces the following error:

TS2345: Argument of type 'TsAction<void, void>' is not assignable to parameter of type 'Action'.
  Property 'type' is missing in type 'TsAction<void, void>' but required in type 'Action'.

It looks like TsAction doesn't expose it's type property which is causing issues with redux's internal Action type.

camfletch commented 5 years ago

Updating to latest redux-thunk and redux appears to have solved the issue. Sorry to bother.