Closed
Description
I know I am not supposed to use values of void
, because one day they might be banned. But for time being I don't understand is it by design or by mistake that the isVoid
guard works whereas isNonVoid
doesn't in the example below:
function isVoid<a>(value: void | a): value is void {
return undefined;
}
function isNonVoid<a>(value: void | a) : value is a {
return undefined;
}
function foo<a>(value: void|a): void {
if (isVoid(value)) {
// value is void
} else {
// value is a
}
}
function baz<a>(value: void|a): void {
if (isNonVoid(value)) {
// value is void | a
} else {
// value is {}
}
}
How come that seemingly identical guard implementation breaks apart entirely?