Describe the bug
When I try matching over a type that has a union property, I get a different result than when I match over a union type with the same property:
// Doesn't work
type Obj = {
type: "foo" | "bar"
}
// Works
// type Obj =
// | {
// type: "foo";
// }
// | {
// type: "bar";
// };
declare const obj: Obj;
match(obj)
.with({ type: "foo" }, () => "adsf")
.otherwise(({ type }) => type satisfies 'bar'); // type is not narrowed correctly with the first Obj type
I understand that this may be due to some limitation, but if that's the case, perhaps the docs could be adjusted to explain this limitation explicitly.
TypeScript playground with a minimal reproduction case
Describe the bug When I try matching over a type that has a union property, I get a different result than when I match over a union type with the same property:
I understand that this may be due to some limitation, but if that's the case, perhaps the docs could be adjusted to explain this limitation explicitly.
TypeScript playground with a minimal reproduction case
Example: Playground
Versions