You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in the migration guide, I've replaced void with undefined in calls to createStandardAction and createAsyncAction.
However, this breaks a few actions where the payload type was SomeType | void. This would previously create an action that could be called both with and without a payload. Now, I have to explicitly send undefined as the payload.
Interestingly, if I revert the change of void to undefined throughout my codebase's calls to create*Action, everything seems to work as expected. Is the move to undefined actually necessary?
Steps to Reproduce
import{createStandardAction}from'typesafe-actions'constpayloadOrUndefined=createStandardAction('ACTION1')<number|undefined>();// Fails to typecheck:// Expected 1 arguments, but got 0// type-helpers.d.ts(69, 72): An argument for 'payload' was not provided.payloadOrUndefined();
Description
As described in the migration guide, I've replaced
void
withundefined
in calls tocreateStandardAction
andcreateAsyncAction
.However, this breaks a few actions where the payload type was
SomeType | void
. This would previously create an action that could be called both with and without a payload. Now, I have to explicitly sendundefined
as the payload.Interestingly, if I revert the change of
void
toundefined
throughout my codebase's calls tocreate*Action
, everything seems to work as expected. Is the move toundefined
actually necessary?Steps to Reproduce
CodeSandbox to help you reproduce issue in isolation
https://codesandbox.io/s/typesafe-actions-reference-project-85nbn
Expected behavior
payloadOrUndefined()
defined above should return an action with typeinstead of failing to typecheck
Suggested solution(s)
Project Dependencies
The text was updated successfully, but these errors were encountered: