Error with SchemaTaggedError and Match: Effect.Effect<unknown, unknown, unknown>
When using SchemaTaggedError with
MatchMatch, I got an Effect.Effect<unknown, unknown, unknown>Effect.Effect<unknown, unknown, unknown> see below: class ProductStatus extends Schema.TaggedClass<ProductStatus>()("ProductStatus", {
status: Schema.literal("inactive", "active"),
cancelledAt: Schema.nullable(Schema.DateFromSelf),
}){}
class SomeSchemaTaggedError extends Schema.TaggedError<SomeSchemaTaggedError>()("SomeSchemaTaggedError", {}){}
class SomeDataTaggedError extends Data.TaggedClass('SomeDataTaggedError')<{
}> {}
//: Effect.Effect<unknown, unknown, unknown> | ProductStatus | SomeDataTaggedError
//Expected: SomeDataTaggedError | SomeSchemaTaggedError | ProductStatus
const op = pipe(
Match.value(new ProductStatus({status: "active", cancelledAt: null})),
Match.not(
{ status: "active" },
(_) => new SomeDataTaggedError()
),
Match.when(
{ cancelledAt: Match.instanceOf(Date) },
(_) => new SomeSchemaTaggedError()
),
Match.orElse(
(ps) =>
new ProductStatus({
...ps,
status: "inactive",
cancelledAt: new Date(),
})
)
);class ProductStatus extends Schema.TaggedClass<ProductStatus>()("ProductStatus", {
status: Schema.literal("inactive", "active"),
cancelledAt: Schema.nullable(Schema.DateFromSelf),
}){}
class SomeSchemaTaggedError extends Schema.TaggedError<SomeSchemaTaggedError>()("SomeSchemaTaggedError", {}){}
class SomeDataTaggedError extends Data.TaggedClass('SomeDataTaggedError')<{
}> {}
//: Effect.Effect<unknown, unknown, unknown> | ProductStatus | SomeDataTaggedError
//Expected: SomeDataTaggedError | SomeSchemaTaggedError | ProductStatus
const op = pipe(
Match.value(new ProductStatus({status: "active", cancelledAt: null})),
Match.not(
{ status: "active" },
(_) => new SomeDataTaggedError()
),
Match.when(
{ cancelledAt: Match.instanceOf(Date) },
(_) => new SomeSchemaTaggedError()
),
Match.orElse(
(ps) =>
new ProductStatus({
...ps,
status: "inactive",
cancelledAt: new Date(),
})
)
);