馃攷 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.
馃攷 Search Terms
TS2565, used before being assigned, checkJs, class field, extends
馃晽 Version & Regression Information
7.0.2,7.1.0-dev.20260928.1@typescript/[email protected], TypeScript 5.x/6.x馃捇 Code
src/product.jswithallowJs,checkJs,strict:馃檨 Actual behavior
馃檪 Expected behavior
No error.
Priceis initialized in the base class. The same code in a.tsfile has no error.