I have created a fresh angular 17 (Node v18.14.1) project.
and tried to run npm run test
It fails with the following error.
Error: src/app/app.component.ts:13:9 - error TS2503: Cannot find namespace 'NodeJS'.
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
export class AppComponent {
title = 'angular-tour-of-heroes';
nodeJsTimeout: NodeJS.Timeout | null = null;
}
I already tried to add types: ["node"]
in tsconfig.app.json
and also in tsconfig.json
. Didnt resolve my problem.
Not sure if this is the right solution of not. But the following type worked for me!
nodeJsTimeout: ReturnType<typeof setInterval> | null = null;