Skip to content

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

Closed
@T18970237136

Description

@T18970237136

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions