Switched on the @typescript-eslint/no-non-null-assertion rule in eslint.
Fixed the errors it threw up.
This commit is contained in:
@@ -157,7 +157,10 @@ export class RecipeDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
addRow() {
|
||||
const formValue = this.form.value.addRow!;
|
||||
const formValue = this.form.value.addRow;
|
||||
if (formValue === undefined) {
|
||||
return;
|
||||
}
|
||||
const quantity = this.math.parseAmount(formValue.quantity, 2);
|
||||
const rate = this.math.parseAmount(formValue.rate, 2);
|
||||
if (this.ingredient === null || quantity <= 0 || rate <= 0) {
|
||||
@@ -198,7 +201,7 @@ export class RecipeDetailComponent implements OnInit, AfterViewInit {
|
||||
2,
|
||||
);
|
||||
this.form.controls.costPrice.setValue(`${costPrice}`);
|
||||
const salePrice = this.math.parseAmount(this.form.value.salePrice!, 2);
|
||||
const salePrice = this.math.parseAmount(this.form.value.salePrice ?? '0', 2);
|
||||
if (salePrice < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -252,9 +255,9 @@ export class RecipeDetailComponent implements OnInit, AfterViewInit {
|
||||
const formModel = this.form.value;
|
||||
this.item.validFrom = moment(formModel.validFrom).format('DD-MMM-YYYY');
|
||||
this.item.validTill = moment(formModel.validTill).format('DD-MMM-YYYY');
|
||||
this.item.recipeYield = this.math.parseAmount(formModel.recipeYield!, 2);
|
||||
this.item.salePrice = this.math.parseAmount(formModel.salePrice!, 2);
|
||||
this.item.costPrice = this.math.parseAmount(formModel.costPrice!, 2);
|
||||
this.item.recipeYield = this.math.parseAmount(formModel.recipeYield ?? '1', 2);
|
||||
this.item.salePrice = this.math.parseAmount(formModel.salePrice ?? '0', 2);
|
||||
this.item.costPrice = this.math.parseAmount(formModel.costPrice ?? '0', 2);
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user