Code:
class Example {
private server: string;
constructor() {
this.setServer();
}
setServer(): void {
this.server = 'server';
}
}
new Example();
Error:
⨯ Unable to compile TypeScript:
src/index.ts:309:13 - error TS2564: Property 'server' has no initializer and is not definitely assigned in the constructor.
309 private server: string;
~~~~~~
Why is TypeScript not complying with the code?