Closed
Description
TypeScript Version: 3.7.x-dev.201xxxxx
3.6,
3.7-beta
Search Terms:
try catch finally never
Code
function f() {
let a: number | null = null;
try {
a = 123;
return a;
}
catch (e) {
throw e; // remove line and error disappears
}
finally {
console.log(a); // works fine, logs 123
if (a != null && a.toFixed(0) == "123") {
// Property 'toFixed' does not exist on type 'never'.(2339)
}
}
}
f();
Expected behavior:
a
should have type number | null
in the finally block.
Actual behavior:
a
has type null
in the finally block and narrowing with a != null
it becoms never
Related Issues: