Skip to content

class initialization fails when #private static field is present together with computed method name #44113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
0kku opened this issue May 17, 2021 · 0 comments · Fixed by #44186
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@0kku
Copy link

0kku commented May 17, 2021

Bug Report

🔎 Search Terms

static ES private fields, static private members, computed class method name, class instantiation fails

🕗 Version & Regression Information

4.3.0-beta

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about static class members
  • I was unable to test this on prior versions because static ES private fields weren't added until 4.3

⏯ Playground Link

Playground link with relevant code

💻 Code

class Foo {
    static #qux = 42;
    ["bar"] () {}
}

new Foo;

🙁 Actual behavior

A runtime error ReferenceError: Cannot access 'Foo' before initialization when using target: "es2021" when trying to instantiate a class that contains both a static ES #private field and a method that has a computed method name. Compiled code runs fine without runtime errors when using target: "ESNEXT" (no downleveling).

🙂 Expected behavior

Code runs without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants