for
-let
+ inner function incorrectly says variable is used before being assigned
#61375
Labels
Milestone
π Search Terms
TS2454
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.8.2#code/PTAEFECdIe0goAZnUAKANgUwC6gB6gyKgDaAjADSgBMAugJSgDe8oboiArgHYDG2ASxjcOqRi3aT8AblbsAvvEXwQoAPIBpUAHcB2ABagAhtBjaOPfkO5IUGHPkLFyVOuLlssuYgF40jHwA+Zg8pPFlJRWVVTR09Q15hAGdsW0g0RO4UxyJSShoGEMkuPkFhUABzMSKpNnDQqKA
π» Code
π Actual behavior
let
variables bound in the head offor
are always assigned in the body.π Expected behavior
No errors.
Additional information about the issue
First noticed when upgrading from 5.6 to 5.7, was lazy and figured someone else would report it.
I figured TS might be incorrectly thinking
f
could be hoisted out of the loop, but it accepts it withconst
, so I don't know.Commit found with
The text was updated successfully, but these errors were encountered: