From d01db82c0dca352de2d7644c383d388fc3ec0366 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Thu, 2 May 2019 14:08:51 +0900 Subject: Types src/content --- src/background/domains/Setting.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/background/domains/Setting.ts') diff --git a/src/background/domains/Setting.ts b/src/background/domains/Setting.ts index 106ec0f..b2b1ff2 100644 --- a/src/background/domains/Setting.ts +++ b/src/background/domains/Setting.ts @@ -1,22 +1,30 @@ import DefaultSettings from '../../shared/settings/default'; import * as settingsValues from '../../shared/settings/values'; +type SettingValue = { + source: string, + json: string, + form: any +} + export default class Setting { - constructor({ source, json, form }) { + private obj: SettingValue; + + constructor({ source, json, form }: SettingValue) { this.obj = { source, json, form }; } - get source() { + get source(): string { return this.obj.source; } - get json() { + get json(): string { return this.obj.json; } - get form() { + get form(): any { return this.obj.form; } @@ -33,11 +41,11 @@ export default class Setting { return { ...settingsValues.valueFromJson(DefaultSettings.json), ...value }; } - serialize() { + serialize(): SettingValue { return this.obj; } - static deserialize(obj) { + static deserialize(obj: SettingValue): Setting { return new Setting({ source: obj.source, json: obj.json, form: obj.form }); } -- cgit v1.2.3