Custom error message for union type in Effect Typescript library

It looks like annotations.message added to Schema.Literal are overridden:

const FooOrBar = Schema.Literal('foo', 'bar').annotations({
    message: () => 'woops' // ignored
})


On parse errors I will get 2 errors with the default message: Expected "foo", actual "hello" and Expected "bar", actual "hello".

I guess I can use Schema.String.pipe(Schema.filter) for these cases but it widens the Type to String

What would be the best approach to get a union type with a single message?
Was this page helpful?