Skip to content

block scoped variable capture errors is not shown if variable is closed in method of local class #5143

Closed
@vladima

Description

@vladima
var data: any = [];
for (let x = 0; x < 10; ++x) {
    class C {
        m() {
            return x + 1;
        }
    }
    data.push(C);
}

for (let c of data) {
    console.log(new c().m());
}

This code is compiled with no errors and prints 11 10 times in runtime

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions