enum E {
A,
B,
C,
}
function f(x: E | undefined) {
return x ?? E.C;
}
Expected f to have type E, but instead it has type E | E.C
Playground
Doesn't have anything to do with ?? - can reproduce it with ||.
enum E {
A = 1,
B,
C,
}
function f(x: E | undefined) {
return x || E.C;
}
Expected
fto have typeE, but instead it has typeE | E.CPlayground
Doesn't have anything to do with
??- can reproduce it with||.