Skip to content

Commit

Permalink
revert removal of non-conforming type check in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
with-heart committed Sep 12, 2024
1 parent cc323c7 commit 838e53a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/actions/raise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ function resolveRaise(
) {
const delaysMap = snapshot.machine.implementations.delays;

if (typeof eventOrExpr === 'string') {
throw new Error(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Only event objects may be used with raise; use raise({ type: "${eventOrExpr}" }) instead`
);
}
const resolvedEvent =
typeof eventOrExpr === 'function'
? eventOrExpr(args, actionParams)
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/actions/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ function resolveSendTo(
) {
const delaysMap = snapshot.machine.implementations.delays;

if (typeof eventOrExpr === 'string') {
throw new Error(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`Only event objects may be used with sendTo; use sendTo({ type: "${eventOrExpr}" }) instead`
);
}
const resolvedEvent =
typeof eventOrExpr === 'function'
? eventOrExpr(args, actionParams)
Expand Down

0 comments on commit 838e53a

Please sign in to comment.