function foo(): never {
throw new Error();
}
const bar = (): never => {
throw new Error();
}
const qux = function():never {
throw new Error();
}
function mainFoo(a: number | undefined): number {
if (a !== undefined) {
return a;
}
foo();
}
function mainBar(a: number | undefined): number {
if (a !== undefined) {
return a;
}
bar();
}
function mainQux(a: number | undefined): number {
if (a !== undefined) {
return a;
}
qux();
}
In the code above, mainBar and mainQux are exhibiting errors as if the return type of bar() and qux() were 'undefined'.
What's inferred differently?
