Microsoft/TypeScript

`using` transform throws when a for body binding shadows the for head binding

Open

#61 714 ouverte le 16 mai 2025

Voir sur GitHub
 (6 commentaires) (1 réaction) (1 assigné)TypeScript (6 726 forks)batch import
BugDomain: API: TransformsFix AvailableHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

🔎 Search Terms

explicit resource management, using, await using, loop initializer, Symbol.dispose, Symbol.asyncDispose, iteration, shadows

🕗 Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250516#code/MYGwhgzhAEBiD29oG8C+BYAUAM3gJ2gAoBXCASwDsBzaXJebaAbQF0BKFLaaYeCiAC61E0ALzQKAUwDucRITYBuLKiA

💻 Code

class Foo {}
for (using foo of []) {
  const foo = new Foo();
}

🙁 Actual behavior

The transformed output throws "redeclaration of const foo "

🙂 Expected behavior

The transformed output should not throw.

Additional information about the issue

Babel is also affected by this issue: https://github.com/babel/babel/issues/17318. We plan to wrap the for body within a new block when it contains shadowed binding.

Guide contributeur