Skip to content

Incorrect emit of defining class expression with static property inside loop #8578

@yuit

Description

@yuit

As @jeffreymorlan points out in the PR #8551, below code is emited incorrectly.

Compiler options: --target es5, --target es6

const arr: {y(): number}[] = [];
for (let i = 0; i < 3; i++) {
    arr.push(class C {
        static x = i;
        static y = () => C.x * 2;
    });
}
arr.forEach(C => console.log(C.y()));

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