-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Closed
Copy link
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
Bug Report
Compiling the code below compiled with the --target ESNext option, an error is thrown.
🕗 Version & Regression Information
- No problem up to
npmversion4.3.0-dev.20210407 - The problem first appears in
npmversion4.3.0-dev.20210408
⏯ Playground Link
Cannot be reproduced in the playground (see #45297)
💻 Code
function writeVal(a: number, b: any): number {
console.log(‘writeVal’, a, b);
return a;
}
class TestClass {
a: number;
public b = writeVal(2, this.z);
constructor(public z: number) {
this.a = writeVal(1, this.z);
}
public c = writeVal(3, this.z);
}🙁 Actual behavior
throws
x.ts:7:33 - error TS2729: Property ‘z’ is used before its initialization.
7 public b = writeVal(2, this.z);
~
x.ts:8:17
8 constructor(public z: number) {
~~~~~~~~~~~~~~~~
‘z’ is declared here.
x.ts:11:33 - error TS2729: Property ‘z’ is used before its initialization.
11 public c = writeVal(3, this.z);
~
x.ts:8:17
8 constructor(public z: number) {
~~~~~~~~~~~~~~~~
‘z’ is declared here.
Found 2 errors.
🙂 Expected behavior
The created javascript file should be
function writeVal(a, b) {
console.log('writeVal', a, b);
return a;
}
class TestClass {
constructor(z) {
this.z = z;
this.b = writeVal(2, this.z);
this.c = writeVal(3, this.z);
this.a = writeVal(1, this.z);
}
}Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code