TypeScript Version: 3.8.0-dev.20200125
Search Terms:
Code
// @target: esnext
// @useDefineForClassFields. true
class C {
bar = () => this.foo1 + this.foo2;
foo1 = '';
constructor(public foo2: string) {}
}
Expected behavior:
Accessing foo1 and foo2 should not be an error as the function is not immediately invoked and therefore the properties are initialized when accessed. This worked before #36425.
Actual behavior:
used before initialization error on this.foo1 and this.foo2
Playground Link: https://www.typescriptlang.org/play/?useDefineForClassFields=true&target=99&ts=3.8.0-dev.20200125&ssl=9&ssc=2&pln=5&pc=2#code/MYGwhgzhAEDC0G8BQ1XQEZgE7QLzQAoBKPAPmgBcALASwgDoAzAe2YEZoBqS2hl5gEwBuFGn4d8Ackki00YMwB2EClgCuwCsywEADmvQgawaPwEAuaCqw1FAcxIIAvkidA
Related Issues: #36425 @sandersn
TypeScript Version: 3.8.0-dev.20200125
Search Terms:
Code
Expected behavior:
Accessing
foo1andfoo2should not be an error as the function is not immediately invoked and therefore the properties are initialized when accessed. This worked before #36425.Actual behavior:
used before initialization error on
this.foo1andthis.foo2Playground Link: https://www.typescriptlang.org/play/?useDefineForClassFields=true&target=99&ts=3.8.0-dev.20200125&ssl=9&ssc=2&pln=5&pc=2#code/MYGwhgzhAEDC0G8BQ1XQEZgE7QLzQAoBKPAPmgBcALASwgDoAzAe2YEZoBqS2hl5gEwBuFGn4d8Ackki00YMwB2EClgCuwCsywEADmvQgawaPwEAuaCqw1FAcxIIAvkidA
Related Issues: #36425 @sandersn