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
|
In tsconfig.json