Effect CommunityEC
Effect Community2y ago
3 replies
staubfuss

Type Inference in TypeScript

Hi, is the inferred type correct or is it a Bug?
type Status = Data.TaggedEnum<{
  SendError: { sendError: Error; recipient: string }
  SendSuccess: { recipient: string }
}>

declare const fn = (): Effect.Effect<Status[]> 
const why = fn().pipe(Effect.map(Array.filter((e) => e._tag === 'SendSuccess')))
/**     ^? Effect.Effect<({
    readonly _tag: "SendError";
    readonly sendError: Error;
    readonly recipient: string;
} | {
    readonly _tag: "SendSuccess";
    readonly recipient: string;
})[], never, never>
*/


And if it is correct do I need to provide Type Information somewhere so I only get SendError as a result type?
Was this page helpful?