I would like to get rid of the Error above. It started to appear after re-installed dependencies using npm i.

I tried removing "implements onInit" and it disappeared So the problem is related to it. But I want to use "implements onInit" without getting this error. I suspect it has to do also with typescript version (Which i upgraded to the latest).

Update: Of course I implemented ngOnInit function inside the class.

Error Message:

Class is using Angular features but is not decorated. Please add an explicit Angular decorator.(-992007)?

Code:

export class SomeClass implements OnInit {
ngOnInit():void{ 
//some code};
}
2

There are 2 best solutions below

2
Naren Murali On

From angular 13 you will be getting this error I guess, if you are using angular features you need a decorator for it, you can simply add a dummy decorator for this and solve your issue!

@Directive()
export class TestClass {

}

implements just enforces that ngOnInit needs to be present inside the class, there is no use for it outside of an angular component!

1
Uri Gross On

This error happened after updating typescript to latest. What I did is to rollback command

npm i [email protected]

And it was fixed.