Skip to content

Incorrect TS1111 when using private generator function in JS#64228

Description

@Ecco

馃攷 Search Terms

An error TS1111 is raised when (properly) using a private generator function. I'm using VSCode, and it will report Private field '#iterate' must be declared in an enclosing class. when calling child.#iterate().

馃晽 Version & Regression Information

  • I'm hitting this in VSCode 1.135.0

馃捇 Code

class Foo {
  *iterate() {
    yield* this.#iterate()
  }

  *#iterate() {
    const child = this.child
    if (child instanceof this.constructor) {
      yield* child.#iterate()
    }
  }
}

let f = new Foo()
for (const i of f.iterate()) {

}

馃檨 Actual behavior

An error TS1111 is raised.

馃檪 Expected behavior

There should be no error.

Additional information about the issue

  1. The error disappears if I call this.#iterate(), but of course that's not the point.
  2. I can also clear the error by adding assert(#iterate in child) before the call

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions