Closed
Description
TypeScript Version: Version 3.5.3
Search Terms:
Class property initialization, error TS2564: Property has no initializer and is not definitely assigned in the constructor.
Code
export class NetworkConnection extends EventEmitter {
private intervalId: NodeJS.Timeout;
public constructor(timeout = 60000) {
super();
this.start(timeout);
}
public start = (timeout: number) => {
this.intervalId = setInterval(this.broadcast, timeout);
};
public stop = () => {
clearInterval(this.intervalId);
};
...
}
Expected behavior:
Run without compile error.
Actual behavior:
error TS2564: Property 'intervalId' has no initializer and is not definitely assigned in the constructor.
Playground Link:
Metadata
Metadata
Assignees
Labels
No labels