aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/RecipePreview.ts
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-09-04 22:10:28 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-09-05 05:01:51 +0530
commit92627555c6b0d56c96a95e31780e3015b3e637e9 (patch)
tree314beb586594c964dc5dbbb77bc47183ba273dd7 /src/models/RecipePreview.ts
parentchore: auto-generated files [skip ci] (diff)
downloadferdium-app-92627555c6b0d56c96a95e31780e3015b3e637e9.tar.gz
ferdium-app-92627555c6b0d56c96a95e31780e3015b3e637e9.tar.zst
ferdium-app-92627555c6b0d56c96a95e31780e3015b3e637e9.zip
refactoring: Use 'ifUndefined*' consistently.
Added some error checking
Diffstat (limited to 'src/models/RecipePreview.ts')
-rw-r--r--src/models/RecipePreview.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/models/RecipePreview.ts b/src/models/RecipePreview.ts
index 351ecf765..4d2cc8450 100644
--- a/src/models/RecipePreview.ts
+++ b/src/models/RecipePreview.ts
@@ -1,5 +1,13 @@
1// @flow 1// @flow
2 2
3interface IRecipePreview {
4 id: string;
5 name: string;
6 icon: string;
7 featured: boolean;
8 aliases: string[];
9}
10
3export default class RecipePreview { 11export default class RecipePreview {
4 id: string = ''; 12 id: string = '';
5 13
@@ -11,9 +19,13 @@ export default class RecipePreview {
11 19
12 aliases: string[] = []; 20 aliases: string[] = [];
13 21
14 constructor(data: { id: any; }) { 22 constructor(data: IRecipePreview) {
23 if (!data) {
24 throw Error('RecipePreview config not valid');
25 }
26
15 if (!data.id) { 27 if (!data.id) {
16 throw Error('RecipePreview requires Id'); 28 throw Error(`RecipePreview '${data.name}' requires Id`);
17 } 29 }
18 30
19 Object.assign(this, data); 31 Object.assign(this, data);