Skip to content

Incorrect downlevel compilation for block scoped bindings captured in class initializers #7714

Description

let ar = [];
for (let i = 0; i < 2; i++) {
  ar.push(class { x = i; });
}
console.log(new ar[0]().x); // should this be 0, now prints 2
console.log(new ar[1]().x); // should this be 1, now prints 2

Activity

  1. modified the milestones: TypeScript 2.1, on Sep 29, 2016
  2. jakebailey commented on Jul 7, 2023

    @jakebailey
    Member

    Just looking at old issues; this one is the same as #8578 and was also fixed by #43197.

  3. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions