Skip to content

In JS, bogus noImplicitAny error on some this-property assignments #26097

Open
@sandersn

Description

@sandersn

Discovered while looking at the puppeteer user test:

class EmulationManager {
  constructor() {
    this._emulatingMobile = false;
  }

  /**
   * @param {boolean} viewport
   */
  emulateViewport(viewport) {
    if (this._emulatingMobile !== viewport)
        return true;
    this._emulatingMobile = viewport;
  }
}

Expected behavior:
No error with noImplicitAny, and this._emulatingMobile: boolean.

Actual behavior:
Error on this._emulatingMobile = false, "implicitly has type 'any' because it is referenced directly or indirectly in its own initialiser, and this.emulatingMobile: any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptcheckJsRelates to checking JavaScript using TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions