Angular Property is used before its initialization error

--

This is now showing up with latest Typescript I will explain why

Issue here was raised: https://github.com/microsoft/TypeScript/issues/53286

That for ES2022

class Foo { 
bar = this.buz;
constructor(private buz: unknown) {}
}

Should error

TS2729: Property 'buz' is used before its initialization.

As well.

This was merged into the latest version of Typescript. If you are coming across this error now that would be why


You can see others complaining here: https://github.com/microsoft/TypeScript/issues/48814

Solution is to set
useDefineForClassFields to false i.e.

useDefineForClassFields: false

Within your tsconfig, now that is by default set to true

--

--

Responses (2)