Switched on the @typescript-eslint/no-non-null-assertion rule in eslint.
Fixed the errors it threw up.
This commit is contained in:
@ -74,7 +74,7 @@ export class EmployeeDetailComponent implements OnInit, AfterViewInit {
|
||||
salary: this.item.salary || '',
|
||||
points: this.item.points || '',
|
||||
isActive: this.item.isActive,
|
||||
costCentre: this.item.costCentre.id!,
|
||||
costCentre: this.item.costCentre.id ?? '',
|
||||
joiningDate: this.item.joiningDate
|
||||
? moment(this.item.joiningDate, 'DD-MMM-YYYY').toDate()
|
||||
: new Date(),
|
||||
@ -130,17 +130,17 @@ export class EmployeeDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
getItem(): Employee {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name!;
|
||||
this.item.designation = formModel.designation!;
|
||||
this.item.salary = +formModel.salary!;
|
||||
this.item.points = +formModel.points!;
|
||||
this.item.isActive = formModel.isActive!;
|
||||
this.item.costCentre.id = formModel.costCentre!;
|
||||
this.item.joiningDate = moment(formModel.joiningDate).format('DD-MMM-YYYY');
|
||||
const formValue = this.form.value;
|
||||
this.item.name = formValue.name ?? '';
|
||||
this.item.designation = formValue.designation ?? '';
|
||||
this.item.salary = +(formValue.salary ?? '0');
|
||||
this.item.points = +(formValue.points ?? '0');
|
||||
this.item.isActive = formValue.isActive ?? true;
|
||||
this.item.costCentre.id = formValue.costCentre ?? '';
|
||||
this.item.joiningDate = moment(formValue.joiningDate).format('DD-MMM-YYYY');
|
||||
this.item.leavingDate = this.item.isActive
|
||||
? null
|
||||
: moment(formModel.leavingDate).format('DD-MMM-YYYY');
|
||||
: moment(formValue.leavingDate).format('DD-MMM-YYYY');
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user