Switched on the @typescript-eslint/no-non-null-assertion rule in eslint.

Fixed the errors it threw up.
This commit is contained in:
2022-07-17 09:17:20 +05:30
parent c76696e022
commit 9f70ec2917
29 changed files with 144 additions and 111 deletions
@@ -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;
}
}
+1 -1
View File
@@ -58,7 +58,7 @@ export class RecipeService {
startDate: string | null,
finishDate: string | null,
): Observable<ProductSku> {
const getUrl: string = `${url}/ingredient-details/${id}`;
const getUrl = `${url}/ingredient-details/${id}`;
const options = {
params: new HttpParams(),
};