Closed
Description
TS 2.4.1 with noImplicitReturns
enabled
class A {}
class B {}
// error: Not all code paths return a value.
const fn = (x: A | B) => {
if (x instanceof A) {
x // A
return 1
} else if (x instanceof B) {
x // B
return 2
} else {
x // never
}
}
I would not expect this to error because the if statement is exhaustive, therefore all code paths do return a value.