Understanding TaggedError and Effect.fail in Effect Typescript Library

I'm having a bit of confusion with:
1. what a new TaggedError looks like internally, and
2. what it's type is?

I know that within a generator, calling yield* new SomeTaggedError() will automatically wrap it within an Effect.fail(...) constructor and sequence it with the preceding effects.

However, what happens if you just return a new SomeTaggedError() directly? It's confusing because i can type it as either a TaggedError class or an Effect.

Is this just interpreted as a normal Error value, or is it wrapped in an Effect.fail that short-circuits?

export class PlatformError extends Data.TaggedError('PlatformError')<{
}> {}

const fn = (x: string) => new PlatformError()


https://effect.website/play/#13c0538af53d
Was this page helpful?