John Yani
John Yani
Bug: can't create an action without payload. 'ActionCreator<void>' is not assignable to '() => void'
See #82
Bug: can't create an action without payload. 'ActionCreator<void>' is not assignable to '() => void'
In addition, we don't want payload to be present: ``` export type Action = Payload extends void ? { type: string; error?: boolean; meta?: Meta; } : { type: string;...
Bug: can't create an action without payload. 'ActionCreator<void>' is not assignable to '() => void'
The issue is that you can't use void as a parameter type in generic: ``` function testAsyncGenericStrictError(params: P, result: R, error: E) { const async = actionCreator.async('ASYNC'); // you can't...
Bug: can't create an action without payload. 'ActionCreator<void>' is not assignable to '() => void'
So it means the default value should be changed to something else that can be type guarded: ``` ( type: string, commonMeta?: Meta, isError?: boolean, ): ActionCreator; ``` Should be...
Bug: can't create an action without payload. 'ActionCreator<void>' is not assignable to '() => void'
Here's how similar issue fixed in redux-toolkit: https://github.com/reduxjs/redux-toolkit/pull/133/files#diff-438bbd0288b07c3e7ae7f40f89f7f451R9-R11 ``` export type SliceActionCreator = P extends void ? () => PayloadAction : (payload: P) => PayloadAction ```
Bug: can't create an action without payload. 'ActionCreator<void>' is not assignable to '() => void'
Oh, this looks even better: https://github.com/reduxjs/redux-toolkit/pull/138 ``` export type SliceActionCreator = [P] extends [void] ? () => PayloadAction : (payload: P) => PayloadAction ```
Well, it breaks a lot of things. Maybe someone else would have a better luck.
Pushed a new version with fixed generics
Published these changed to `typescript-fsa-vanuan` and `typescript-fsa-reducers-vanuan`
This appears to be an issue of parameter destructuring where default value contains typescriptBraces. 