TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

"Block-scoped variable used before its declaration" not detected in some cases

Open T18970237136 opened this issue 10 years ago • 0 comments

Hi, this is probably only a minor/cosmetic issue, but while trying the code in https://bugzilla.mozilla.org/show_bug.cgi?id=1069480, I found that the Typescript Compiler does not detect that a variable is used before its initialization in a for-of loop with object destructuring using a computed property name.

TypeScript Version: master (a75a02c)

Code (Playground)

"use strict";

// 1:
for (let {[a]: a} of [{ }]) continue;

// 2:
for (let {[a]: a} = { }; false; ) continue;

// 3:
let {[b]: b} = { };

Expected behavior: For 1), 2) and 3) the error "Block-scoped variable used before its declaration" should be reported.

Actual behavior: No error reported for 1), correct errors reported for 2) and 3).

Thanks!

T18970237136 avatar Mar 11 '16 08:03 T18970237136