fix(42678): detect access to uninitialized variable in IIFE (#42776)

* fix(42678): detect access to uninitialized variable in IIFE

* improve performance

* Add missing space to match coding guidelines

* simplify the implementation

Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
Zzzen
2021-12-07 02:42:20 +08:00
committed by GitHub
parent 1f275d705d
commit 7a1687de26
7 changed files with 201 additions and 3 deletions

View File

@@ -102,3 +102,23 @@ function foo14() {
}
let x
}
function foo15() {
// https://github.com/microsoft/TypeScript/issues/42678
const [
a,
b,
] = ((): [number, number] => {
(() => console.log(a))(); // should error
console.log(a); // should error
const b = () => a; // should be ok
return [
0,
0,
];
})();
}
function foo16() {
let [a] = (() => a)();
}