We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
variable reference foreach before declaration
https://www.typescriptlang.org/play?ts=5.4.2#code/MYewdgzgLgBADjAXDaAnAlmA5gbQLowC8MOA5AKYAeAhgLZwA25peA3AFBwB0AZiKgFFqwABYAKSkQB8MAN7sYMdDxgTC6ygEo5CxTACeXOAFcI42QF9NHRRfZWOoSLH1ESbIA
const p = []; p.forEach(x => { if (x===x) { y.push({}); } }); const y = [];
Usage of y in foreeach doesn't lead to compilation error. But it produces a runtime error.
Compilation error on line y.push({});
y.push({});
No response
The text was updated successfully, but these errors were encountered:
Duplicate of #56827 / #11498.
Sorry, something went wrong.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
π Search Terms
variable reference foreach before declaration
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.4.2#code/MYewdgzgLgBADjAXDaAnAlmA5gbQLowC8MOA5AKYAeAhgLZwA25peA3AFBwB0AZiKgFFqwABYAKSkQB8MAN7sYMdDxgTC6ygEo5CxTACeXOAFcI42QF9NHRRfZWOoSLH1ESbIA
π» Code
π Actual behavior
Usage of y in foreeach doesn't lead to compilation error. But it produces a runtime error.
π Expected behavior
Compilation error on line
y.push({});
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: