From 1281598b72aba59b5db9183070e46110a23d4c93 Mon Sep 17 00:00:00 2001 From: Jose Medina Date: Wed, 12 Apr 2017 16:08:07 -0700 Subject: [PATCH] Added type definitions for electron-config --- .../electron-config/electron-config-tests.ts | 29 ++++++++ types/electron-config/index.d.ts | 70 +++++++++++++++++++ types/electron-config/tsconfig.json | 22 ++++++ types/electron-config/tslint.json | 1 + 4 files changed, 122 insertions(+) create mode 100644 types/electron-config/electron-config-tests.ts create mode 100644 types/electron-config/index.d.ts create mode 100644 types/electron-config/tsconfig.json create mode 100644 types/electron-config/tslint.json diff --git a/types/electron-config/electron-config-tests.ts b/types/electron-config/electron-config-tests.ts new file mode 100644 index 0000000000..bf1ad2087b --- /dev/null +++ b/types/electron-config/electron-config-tests.ts @@ -0,0 +1,29 @@ +import ElectronConfig = require('electron-config'); + +new ElectronConfig({ + defaults: {}, +}); + +new ElectronConfig({ + name: 'myConfiguration', +}); + +const electronConfig = new ElectronConfig(); + +electronConfig.set('foo', 'bar'); +electronConfig.set({ + foo: 'bar', + 'foo2': 'bar2', +}); +electronConfig.delete('foo'); +electronConfig.get('foo'); +electronConfig.has('foo'); +electronConfig.clear(); +electronConfig.size; +electronConfig.store; + +electronConfig.store = { + foo: 'bar', +}; + +electronConfig.path; diff --git a/types/electron-config/index.d.ts b/types/electron-config/index.d.ts new file mode 100644 index 0000000000..afb526d921 --- /dev/null +++ b/types/electron-config/index.d.ts @@ -0,0 +1,70 @@ +// Type definitions for electron-config 0.2.1 +// Project: https://github.com/sindresorhus/electron-config +// Definitions by: Jose M. Medina , Daniel P. Alvarez +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface ElectronConfigOptions { + /** + * Default config. + */ + defaults?: {}; + + /** + * Name of the config file (without extension). + */ + name?: string; +} + +declare class ElectronConfig implements Iterable<[string, string | number | boolean | symbol | {}]> { + /** + * gets the item count + */ + size: number; + + /** + * Get all the config as an object or replace the current config with an object + */ + store: {}; + + /** + * Get the path to the config file. + */ + path: string; + constructor(options?: ElectronConfigOptions); + + /** + * Sets an item + */ + set(key: string, value: any): void; + + /** + * Sets multiple items at once + */ + set(object: {}): void; + + /** + * deletes an item + */ + delete(key: string): void; + + /** + * retrieves an item + */ + get(key: string): any; + + /** + * Checks if an item exists + */ + has(key: string): boolean; + + /** + * deletes all items + */ + clear(): void; + + [Symbol.iterator](): Iterator<[string, string | number | boolean | symbol | {}]>; +} + +declare namespace ElectronConfig {} // https://github.com/Microsoft/TypeScript/issues/5073 + +export = ElectronConfig; diff --git a/types/electron-config/tsconfig.json b/types/electron-config/tsconfig.json new file mode 100644 index 0000000000..0d3777a09e --- /dev/null +++ b/types/electron-config/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "electron-config-tests.ts" + ] +} diff --git a/types/electron-config/tslint.json b/types/electron-config/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/types/electron-config/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }