I have encountered warnings in VSCode while using certain properties in my Angular component. The warnings state:
'_id' is declared but its value is never read.ts(6133)
(property) ItemEditComponent._id: number | undefined
'_isModeEdit' is declared but its value is never read.ts(6133)
(property) ItemEditComponent._isModeEdit: boolean
Below is the code snippet of my component:
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Params } from '@angular/router';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-item-edit',
standalone: true,
imports: [CommonModule],
templateUrl: './item-edit.component.html',
styleUrls: ['./item-edit.component.scss'],
})
export class ItemEditComponent implements OnInit, OnDestroy {
private _route = inject(ActivatedRoute);
private _routeParamsSub: Subscription = new Subscription();
private _id: number | undefined = undefined;
private _isModeEdit = false;
ngOnInit(): void {
this._routeParamsSub = this._route.params.subscribe((params: Params) => {
this._initPage(+params['id']);
});
}
ngOnDestroy(): void {
this._routeParamsSub.unsubscribe();
}
_initPage(id: number | undefined) {
if (!id) return;
this._id = id;
this._isModeEdit = true;
}
}
Despite utilizing these variables within the component, I am still receiving warnings. Any insights into why these warnings persist would be greatly appreciated. Thank you.