I’m using some properties in my Angular component, but I’m getting the following warnings in VSCode:
'_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
This is also 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; // I'm getting the warning for this variable!
private _isModeEdit = false; // And this one!
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;
}
}
As you can see, I’m actually using the variables! Any ideas why I’m seeing such warnings? Thanks in advance.
>Solution :
You are not using the variables. Assignment isn’t using