3 ms·
I don't think it's any easier. Narrowing works the same way with the in operator. If A, B and C each have a single property with the same name: function f(x:
by TheCoelacanth 5y ago
I don't think it's any easier. Narrowing works the same way with the in operator. If A, B and C each have a single property with the same name:
function f(x: A | B | C) {
if ('A' in x) {
// x is narrowed to A
} else {
// x is narrowed to B | C
}
}