Effect CommunityEC
Effect Community2y ago
49 replies
imagio

Why is `_tag` required when decoding a `TaggedRequest` Schema?

Is there a reason why _tag becomes required when decoding a TaggedRequest Schema?

class SomeSchema extends Schema.TaggedRequest<SomeSchema>()("DoStuff", Schema.void, ThingSchema, {
    id: Schema.string,
    foo: Schema.string,
}) { }
// Property '_tag' is missing in type '{ id: string; foo: string; }' but required in type '{ readonly _tag: "DoStuff"; readonly id: string; readonly foo: string; }'
const bar = Schema.decodeSync(SomeSchema)({ id: "asdf", foo: "bar" })


It's not required by the constructor but is required when decoding.
Was this page helpful?