const Something = (a: number) => {
if (a > 0) return Effect.fail('bad')
return Effect.succeed({ yay: true } as const)
}
const something = Something(0)
// something: Effect.Effect<{ yay: true }> | Effect.Effect<never, 'bad', never>
// rather than: Effect.Effect<{ yay: true }, 'bad', never>
pipe(
something,
// Argument of type '<E, R>(self: Effect<never, E, R>) => Effect<unknown, unknown, unknown>' is not assignable to parameter of type '(a: Effect<never, string, never> | Effect<{ readonly yay: true; }, never, never>) => Effect<unknown, unknown, unknown>'.
// Types of parameters 'self' and 'a' are incompatible.
// Type 'Effect<never, string, never> | Effect<{ readonly yay: true; }, never, never>' is not assignable to type 'Effect<never, string, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type 'Effect<{ readonly yay: true; }, never, never>' is not assignable to type 'Effect<never, string, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type '{ readonly yay: true; }' is not assignable to type 'never'.
Effect.andThen((a) => {
// a: never
return a
})
)
// Works fine
Effect.andThen(something, (a) => a)
const Something = (a: number) => {
if (a > 0) return Effect.fail('bad')
return Effect.succeed({ yay: true } as const)
}
const something = Something(0)
// something: Effect.Effect<{ yay: true }> | Effect.Effect<never, 'bad', never>
// rather than: Effect.Effect<{ yay: true }, 'bad', never>
pipe(
something,
// Argument of type '<E, R>(self: Effect<never, E, R>) => Effect<unknown, unknown, unknown>' is not assignable to parameter of type '(a: Effect<never, string, never> | Effect<{ readonly yay: true; }, never, never>) => Effect<unknown, unknown, unknown>'.
// Types of parameters 'self' and 'a' are incompatible.
// Type 'Effect<never, string, never> | Effect<{ readonly yay: true; }, never, never>' is not assignable to type 'Effect<never, string, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type 'Effect<{ readonly yay: true; }, never, never>' is not assignable to type 'Effect<never, string, never>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
// Type '{ readonly yay: true; }' is not assignable to type 'never'.
Effect.andThen((a) => {
// a: never
return a
})
)
// Works fine
Effect.andThen(something, (a) => a)