Skip to content

Commit 814e5b8

Browse files
alex-dixontim-smartmikearnaldi
authoredMar 16, 2024··
Prevent Effect.if from crashing when first argument is not an Effect (#2299)
Co-authored-by: Tim <hello@timsmart.co> Co-authored-by: Michael Arnaldi <michael.arnaldi@effectful.co>
1 parent 6b20bad commit 814e5b8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎.changeset/wicked-apples-press.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"effect": patch
3+
---
4+
5+
Prevent Effect.if from crashing when first argument is not an Effect

‎packages/effect/src/internal/core.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,8 @@ export const if_ = dual<
952952
(self: boolean | Effect.Effect<unknown, unknown, unknown>, { onFalse, onTrue }: {
953953
readonly onTrue: Effect.Effect<unknown, unknown, unknown>
954954
readonly onFalse: Effect.Effect<unknown, unknown, unknown>
955-
}) => typeof self === "boolean" ? (self ? onTrue : onFalse) : flatMap(self, (b) => (b ? onTrue : onFalse))
955+
// eslint-disable-next-line no-extra-boolean-cast
956+
}) => isEffect(self) ? flatMap(self, (b) => (b ? onTrue : onFalse)) : Boolean(self) ? onTrue : onFalse
956957
)
957958

958959
/* @internal */

0 commit comments

Comments
 (0)
Please sign in to comment.