Closed
Description
TypeScript Version: 2.0.3
Code
With --strictNullChecks
,
class A {
constructor() { }
method() { }
}
let a: A | null = null;
try {
a = new A();
} finally {
if (a) {
a.method();
}
}
Expected behavior:
I expect this to compile. TypeScript should be able to deduce that a
can be of type A
at the a.method()
call site.
Actual behavior:
I get an error message
Property 'method' does not exist on type 'never'.
Note that it works fine if the try and finally lines are removed.