Skip to content

Private [Symbol.asyncIterator] and [Symbol.iterator] methods incorrectly reported as unused #42051

@wojpawlik

Description

@wojpawlik

TypeScript Version: 4.2.0-dev.20201219

Search Terms:

Symbol.iterator Symbol.asyncIterator

Code

export class Polling {
  private async *[Symbol.asyncIterator]() {}
  private *[Symbol.iterator]() {}

  async loop() {
    for await (const updates of this) {
      void updates
    }
  }
  syncLoop() {
    for (const updates of this) {
      void updates
    }
  }
}

Expected behavior:
No errors.

Actual behavior:

'[Symbol.asyncIterator]' is declared but its value is never read.
'[Symbol.iterator]' is declared but its value is never read.

Playground Link

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Suggestion DiagnosticsNon-error squiggles that appear in the editor suggesting that you should do something

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions