Closed edemaine closed 2 weeks ago
One solution to help TypeScript is to declare the results as
let results;results=[]
. This gives it the proper union type of all possible exits from the loop.
Good idea! Implemented, and it seems to work well.
I also removed results=[]
in the special case of loop
containing break with
but not break
.
Fixes #1395
TODO: Documentation
An issue with TypeScript is clear in the
loop
example: we havelet results = []
but laterresults = 'done'
. Perhaps we could detect specifically aloop
that has no plainbreak
and thus will only be exited viabreak with
, and then we could just writelet results
.