After setting up Angular 15, I encountered issues with components using lifecycle hooks like OnInit. An error message stating 'Class is using angular features but is not decorated. Please add an explicit Angular decorator' appeared.
Code Sample Component Code:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-nav',
templateUrl: './nav.component.html',
styleUrls: ['./nav.component.css']
})
export class NavComponent implements OnInit {
ngOnInit(): void {
throw new Error('Method not implemented.');
}
}
Packages:
{
"name": "new",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
// Other dependencies listed here
}
I attempted to update and downgrade @angular/core and typescript in order to resolve the issue.
If I install a TypeScript version lower than 4.8, the error disappears. However, ng serve requires TypeScript version 4.8.2 or higher to run successfully
The error occurs after the completion of ngcc execution