Skip to content

TS2565 false positive in JS for a class field initialized in the base class聽#64520

Description

馃攷 Search Terms

TS2565, used before being assigned, checkJs, class field, extends

馃晽 Version & Regression Information

馃捇 Code

src/product.js with allowJs, checkJs, strict:

export class BaseProduct {
  Price = 0
}

export class Product extends BaseProduct {
  Compute() {
    this.Price = Number(this.Price);
  }
}

馃檨 Actual behavior

src/product.js(7,30): error TS2565: Property 'Price' is used before being assigned.

馃檪 Expected behavior

No error. Price is initialized in the base class. The same code in a .ts file has no error.

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

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions