Skip to content

Commit

Permalink
Fixed forwardTo, escalate and sendUpdate to be compatible with …
Browse files Browse the repository at this point in the history
…required action types (#3913)

* Fixed `forwardTo`, `escalate` and `sendUpdate` to be compatible with required action types

* Create .changeset/nasty-suns-film.md
  • Loading branch information
Andarist committed Mar 23, 2023
1 parent ce96f6d commit 1c18746
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-suns-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"xstate": patch
---

Fixed `forwardTo`, `escalate` and `sendUpdate` to be compatible with required action types
10 changes: 5 additions & 5 deletions packages/core/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export function sendTo<
export function sendUpdate<TContext, TEvent extends EventObject>(): SendAction<
TContext,
TEvent,
AnyEventObject
any
> {
return sendParent(actionTypes.update);
}
Expand Down Expand Up @@ -627,7 +627,7 @@ export function pure<
export function forwardTo<TContext, TEvent extends EventObject>(
target: Required<SendActionOptions<TContext, TEvent>>['to'],
options?: SendActionOptions<TContext, TEvent>
): SendAction<TContext, TEvent, AnyEventObject> {
): SendAction<TContext, TEvent, any> {
if (!IS_PRODUCTION && (!target || typeof target === 'function')) {
const originalTarget = target;
target = (...args) => {
Expand Down Expand Up @@ -663,7 +663,7 @@ export function escalate<
>(
errorData: TErrorData | ExprWithMeta<TContext, TEvent, TErrorData>,
options?: SendActionOptions<TContext, TEvent>
): SendAction<TContext, TEvent, AnyEventObject> {
): SendAction<TContext, TEvent, any> {
return sendParent<TContext, TEvent>(
(context, event, meta) => {
return {
Expand Down Expand Up @@ -759,15 +759,15 @@ export function resolveActions<TContext, TEvent extends EventObject>(
}
case actionTypes.send:
const sendAction = resolveSend(
actionObject as SendAction<TContext, TEvent, AnyEventObject>,
actionObject as SendAction<TContext, TEvent, any>,
updatedContext,
_event,
machine.options.delays as any
) as SendActionObject<TContext, TEvent>; // TODO: fix ActionTypes.Init

if (!IS_PRODUCTION) {
const configuredDelay = (
actionObject as SendAction<TContext, TEvent, AnyEventObject>
actionObject as SendAction<TContext, TEvent, any>
).delay;
// warn after resolving as we can create better contextual message here
warn(
Expand Down

0 comments on commit 1c18746

Please sign in to comment.