diff options
Diffstat (limited to 'src/shared/settings/Properties.ts')
-rw-r--r-- | src/shared/settings/Properties.ts | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/shared/settings/Properties.ts b/src/shared/settings/Properties.ts index 63ff991..27fb62e 100644 --- a/src/shared/settings/Properties.ts +++ b/src/shared/settings/Properties.ts @@ -1,3 +1,4 @@ + export type PropertiesJSON = { hintchars?: string; smoothscroll?: boolean; @@ -65,22 +66,7 @@ export default class Properties { this.complete = complete || defaultValues.complete; } - static fromJSON(json: any): Properties { - let defNames: Set<string> = new Set(defs.map(def => def.name)); - let unknownName = Object.keys(json).find(name => !defNames.has(name)); - if (unknownName) { - throw new TypeError(`Unknown property name: "${unknownName}"`); - } - - for (let def of defs) { - if (!Object.prototype.hasOwnProperty.call(json, def.name)) { - continue; - } - if (typeof json[def.name] !== def.type) { - throw new TypeError( - `property "${def.name}" is not ${def.type}`); - } - } + static fromJSON(json: PropertiesJSON): Properties { return new Properties(json); } |