Angular 14 cannot find Namespace 'NodeJS'


can’t initialize the interval variable

    this.interval = setInterval (() => {
        this.intervalFired.emit(this.lastno + 1);
    }, 1000);

Angular program to see at console.log with start and stop clicks in Angular 14

>Solution :

the problem is that you probably have

interval?: NodeJS.Timeout

that is only while running in an NodeJs environment, when in browser that is not correct value anymore, so instead to maintain the type you can do this.

interval?: ReturnType<typeof setInterval>

this will work regardless if browser or nodejs

Leave a ReplyCancel reply