You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code
Compile with strictNullChecks = true
Playground link: here (make sure to enable strictNullChecks)
classA{a: string;}letfoo: A|undefined=void0;try{foo=newA();thrownewError();}catch(e){if(foo){foo.a;// ERROR: Property 'a' does not exist on type 'never'.}}finally{if(foo){foo.a;// ERROR: Property 'a' does not exist on type 'never'.}}
Expected behavior:
Should compile without errors
Actual behavior:
Compilation fails at the indicated lines. Control flow analysis assumes that foo is of type undefined as it enters the try / catch / finally block, and is unable to detect that foo will actually be of type A in both the catch and finally blocks.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.4.1
Code
Compile with
strictNullChecks = true
Playground link: here (make sure to enable
strictNullChecks
)Expected behavior:
Should compile without errors
Actual behavior:
Compilation fails at the indicated lines. Control flow analysis assumes that
foo
is of typeundefined
as it enters thetry
/catch
/finally
block, and is unable to detect thatfoo
will actually be of typeA
in both thecatch
andfinally
blocks.Likely related to #15835 and #18478
The text was updated successfully, but these errors were encountered: