Does the Match module support exhaustive checks for nested objects?
Hi, I'm trying to use the Match module. Does exhaustive support nested objects?
enum En {
A = "0",
B = "1",
C = "2",
}
type Ex = {
fieldA: "left" | "right";
fieldC: {
subA: En;
};
};
Match.type<Ex>().pipe(
Match.when({ fieldA: "left", fieldC: { subA: En.A } }, () => ""),
Match.when({ fieldA: "left", fieldC: { subA: En.B } }, () => ""),
Match.when({ fieldA: "left", fieldC: { subA: En.C } }, () => ""),
Match.when({ fieldA: "right", fieldC: { subA: En.A } }, () => ""),
Match.when({ fieldA: "right", fieldC: { subA: En.B } }, () => ""),
Match.when({ fieldA: "right", fieldC: { subA: En.C } }, () => ""),
// type error
Match.exhaustive,
);enum En {
A = "0",
B = "1",
C = "2",
}
type Ex = {
fieldA: "left" | "right";
fieldC: {
subA: En;
};
};
Match.type<Ex>().pipe(
Match.when({ fieldA: "left", fieldC: { subA: En.A } }, () => ""),
Match.when({ fieldA: "left", fieldC: { subA: En.B } }, () => ""),
Match.when({ fieldA: "left", fieldC: { subA: En.C } }, () => ""),
Match.when({ fieldA: "right", fieldC: { subA: En.A } }, () => ""),
Match.when({ fieldA: "right", fieldC: { subA: En.B } }, () => ""),
Match.when({ fieldA: "right", fieldC: { subA: En.C } }, () => ""),
// type error
Match.exhaustive,
);