Effect CommunityEC
Effect Community14mo ago
132 replies
Stephen Bluck

Ensuring Accurate Effect Type Dependencies in TypeScript

I like to give types to my Effect's. It helps me reason about the code and doesn't require me to read implementation details. It's also good for code reviews when working in a team environment. One foot-gun I have noticed though is that I can accidentally say that my Effect requires something when in reality it does not. Is there something I can do with the types to get a type error instead?

Here is an example:
const EffectFoo: Effect.Effect<void, never, Foo> = Foo.pipe(Effect.tap(Effect.log))

// I would like a type error here because EffectFoo does not actually require Bar.
const EffectFooBarButNotReally: Effect.Effect<void, never, Foo | Bar> = effectFoo
Was this page helpful?