TypeScript show following error message to this code samples:
class MyClass { someField: boolean; constructor() { return { someField: true }; } }
Solution 1
Add (!) sign after name:
someField!:string;
Solution 2
Open TypeScript config file tsconfig.json and add this code to compiler options
tsconfig.json
"angularCompilerOptions": { // ... "strictPropertyInitialization": false // ... }
Note: it will make static analysis weaker