mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
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:
@@ -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)();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user