@PatrickRoberts that's what happens. For TS, what you have there is a function which means it would be executed
later. As such, it's not possible to guarantee that the state of
foo
is going to be the same between execution and definition time. Now
we as programmers can make that inference because we know that the function is going to be executed before anything else has modifies
foo
. However, that's not applicable in all cases and it's more work for the compiler to try and find this out.
Similar problem here. —
VLAZ 42 secs ago