TypeScript show following error message to this code samples:
class MyClass {
someField: boolean;
constructor() {
return { someField: true };
}
}
Property 'someField' has no initializer and is not definitely assigned in the constructor.
(property) MyClass.someField: boolean
TypeScript Playground (You need to enable strictNullChecks and strictPropertyInitialization to see this error message.)
Given code snippet is simplified from my original script. I would like to return the constructed value instead of assign values to this in constructor. What should I do to make TypeScript works without mentioned error?