Acknowledgement
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?
functionfoo(): never{thrownewError();}constbar=(): never=>{thrownewError();}constqux=function():never{thrownewError();}functionmainFoo(a: number|undefined): number{if(a!==undefined){returna;}foo();}functionmainBar(a: number|undefined): number{if(a!==undefined){returna;}bar();}functionmainQux(a: number|undefined): number{if(a!==undefined){returna;}qux();}(playground)

Acknowledgement
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?
(playground)