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
// @strictNullChecksdeclarefunctionopenFile(): voiddeclarefunctioncloseFile(): voiddeclarefunctionsomeOperation(): {}varresult: {}openFile()try{result=someOperation()}finally{closeFile()}result// error here
Expected behavior:
The code should compile. As #9260 (comment) goes, the try ... finally ... is a grammatical construct. If someOperation breaks the control flow, code after try-finally block will not be reachable. So result after block must be assigned.
Actual behavior:
Error as commented.
Related issues:
I have found a lot flow related issues. But they are more about closure/function declaration than try-catch-finally. So I think this is not a duplicate.
The text was updated successfully, but these errors were encountered:
TypeScript Version: nightly (2.1.0-dev.20161112), --stricNullChecks
Note: this code compiles under 2.0.9
Code
Expected behavior:
The code should compile. As #9260 (comment) goes, the
try ... finally ...
is a grammatical construct. IfsomeOperation
breaks the control flow, code after try-finally block will not be reachable. Soresult
after block must be assigned.Actual behavior:
Error as commented.
Related issues:
I have found a lot flow related issues. But they are more about closure/function declaration than try-catch-finally. So I think this is not a duplicate.
The text was updated successfully, but these errors were encountered: