Closed as not planned
Closed as not planned
Description
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
In the code below, mainBar and mainQux are exhibiting errors as if the return type of bar() and qux() were 'undefined'.
Is it by intention or is it kind of a bug?
If it's so by intention, What's inferred differently?
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();
}