diff options
author | Vijay A <avijayr@protonmail.com> | 2021-09-04 22:10:28 +0530 |
---|---|---|
committer | Vijay A <avijayr@protonmail.com> | 2021-09-05 05:01:51 +0530 |
commit | 92627555c6b0d56c96a95e31780e3015b3e637e9 (patch) | |
tree | 314beb586594c964dc5dbbb77bc47183ba273dd7 /src/models/RecipePreview.ts | |
parent | chore: auto-generated files [skip ci] (diff) | |
download | ferdium-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.ts | 16 |
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 | ||
3 | interface IRecipePreview { | ||
4 | id: string; | ||
5 | name: string; | ||
6 | icon: string; | ||
7 | featured: boolean; | ||
8 | aliases: string[]; | ||
9 | } | ||
10 | |||
3 | export default class RecipePreview { | 11 | export 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); |