diff options
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); |