TypeScript Version: 2.5.0-dev.20170618
Code
function fail1() {
throw new Error()
}
const fail2 = function () {
throw new Error()
}
Expected behavior:
Inferred return type of both functions is never
Actual behavior:
Only the return type of the second function is never. The return type of fail1 is inferred as void.
This is by design. We had it the way you suggest originally but I was too much of a breaking change. See #8767 for more details.
@ahejlsberg Could we have an off-by-default compiler flag that unifies this behavior?
Perhaps only class methods should get void inference :rose:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
I really like @basarat's suggestion.
Most helpful comment
Perhaps only class methods should get
voidinference :rose: