Closed
Description
Bug Report
It may not be a bug, because I see that you clearly know what TDZ check is (such as the code example in this issue), but it is not applied. I did find some related issues reported by TypeScript team members such as #5174 several years before, but it still passes the check now.
Just out of curiosity, would you please explain why such checks are not (fully) implemented?
🔎 Search Terms
TDZ check
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries.
⏯ Playground Link
Playground link with relevant code
💻 Code
// https://github.com/microsoft/TypeScript/issues/5174
function f(x: number) {
switch(x) {
case 1:
let x = 1;
case 2:
x = 2; // should be error because of TDZ
}
}
// https://github.com/microsoft/TypeScript/issues/52924#issue-1595962667
function h() {
let result = g();
let x: number = 10;
return result;
function g() {
return x;
}
}
🙁 Actual behavior
No error reported.
🙂 Expected behavior
TDZ check should be applied.