Closed
Description
TypeScript Version: nightly (2.1.0-dev.20161112), --stricNullChecks
Note: this code compiles under 2.0.9
Code
// @strictNullChecks
declare function openFile(): void
declare function closeFile(): void
declare function someOperation(): {}
var result: {}
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.