Readdy Write

Property 'id' has no initializer and is not definitely assigned in the constructor.ts(2564)

04.02.2023 (👁3253)

Property 'id' has no initializer and is not definitely assigned in the constructor.ts(2564)

 

Fehlermeldung

Property 'id' has no initializer and is not definitely assigned in the constructor.ts(2564)

 

Vorkommen: in der Angular compontent.ts datei wird eine lokale Variable in TypeScript erstellt

Lokale Variable in component.ts

id: number;

Lösung 1:

Variable nullable machen mit ! Ausrufezeichen

id!: number;

Lösung 2:

Variable undefined anhängen beim start

id: number undefined;

 

Global Solution

Add the following line in tsconfig.json

"strictPropertyInitialization": false,//*added

 

Fehler in Visual Code angezeigt

Ein Bild, das Text, Monitor, Screenshot enthält.

Automatisch generierte Beschreibung

In tsconfig.json

Ein Bild, das Text enthält.

Automatisch generierte Beschreibung


0,00 €