TS 2.4.1 with noImplicitReturns enabled
classA{}classB{}// error: Not all code paths return a value.constfn=(x: A|B)=>{if(xinstanceofA){x// Areturn1}elseif(xinstanceofB){x// Breturn2}else{x// never}}I would not expect this to error because the if statement is exhaustive, therefore all code paths do return a value.
TS 2.4.1 with
noImplicitReturnsenabledI would not expect this to error because the if statement is exhaustive, therefore all code paths do return a value.