Closed Methuselah96 closed 6 years ago
@Methuselah96 thanks for reporting, I'll look into it today
@Methuselah96 Ok it's fixed now! Check new release typesafe-actions@1.2.0-rc.4 Please ping me if this is fixed correctly. Thanks
@piotrwitek It works. Thanks!
I'm currently using v1.2.0-rc.1 to take advantage of the new TypeScript features. However when I use
buildAction
to make an action creator with a payload that is a union type I'm running into issues. Here's what my build action looks like:action: buildAction('ACTION').payload<string | null>(),
When I try to build it gives me a type error:
Error:(117, 14) TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((payload: null) => PayloadAction<"ACTION", null>) | ((payload: string) => PayloadAction<"AC...' has no compatible call signatures.
The same thing happens with booleans, since they are a union of true and false:
Error:(44, 12) TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((payload: true) => PayloadAction<"ACTION", true>) | ((payload: false) => Payloa...' has no compatible call signatures.
This issue on the TypeScript repo might be helpful: https://github.com/Microsoft/TypeScript/issues/4612