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
{{ message }}
Repository navigation
Data-first Effect.catchTag doesn't typecheck when self is an inline Effect.map call #10889
import{Data,Effect}from"effect"classNotFoundextendsData.TaggedError("NotFound"){}declareconstlookup: Effect.Effect<number,NotFound>constdoubled=Effect.map(lookup,(n)=>n*2)// Compilesexportconstworks=Effect.catchTag(doubled,"NotFound",()=>Effect.succeed(0))// Error: No overload matches this call.exportconstfails=Effect.catchTag(Effect.map(lookup,(n)=>n*2),"NotFound",()=>Effect.succeed(0))
The second call reports:
No overload matches this call.
The last overload gave the following error.
Argument of type 'string' is not assig 'readonly [never, ...never[]]'.
Inside Effect.gen, yield* Effect.catchTag(Effect.map(...), "NotFound", ...) also reports that the result has no [Symbol.iterator](), because the en and returns a function.
What is the expected behavior?
Both calls typecheck, since they only differ in whether self is held in a variable first.
What do you see instead?
The inline version fails. It happens with TypeScript 7.0.2 and 5.9.3.
Additional information
Writing out the callback's parameter type ((n: number) => n * 2) doesn't help, so it isn't about inferring the callback.
An inline Effect.fail(new NotFound()) as self works.
Effect.catchTags(Effect.map(...), { NotFound: ... }) and Effect.mapError(Effect.map(...), ...) work, so it seems specific to catchTag's overloads. The data-last overload also takes up to three arguments (k, f, orElse), the same number as a data-first call, and K depends on E inferred from self.
Activity