Add types for electron-store 1.2

This commit is contained in:
Daniel Perez Alvarez
2017-07-07 16:45:04 -07:00
parent 338dcf797f
commit e91d21d658
4 changed files with 142 additions and 0 deletions
@@ -0,0 +1,34 @@
import ElectronStore = require('electron-store');
new ElectronStore({
defaults: {}
});
new ElectronStore({
name: 'myConfiguration',
cwd: 'unicorn'
});
const electronStore = new ElectronStore();
electronStore.set('foo', 'bar');
electronStore.set({
foo: 'bar',
foo2: 'bar2'
});
electronStore.delete('foo');
electronStore.get('foo');
electronStore.get('foo', 42);
electronStore.has('foo');
electronStore.clear();
electronStore.openInEditor();
electronStore.size;
electronStore.store;
electronStore.store = {
foo: 'bar'
};
electronStore.path;
+79
View File
@@ -0,0 +1,79 @@
// Type definitions for electron-store 1.2
// Project: https://github.com/sindresorhus/electron-store
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface ElectronStoreOptions {
/**
* Default config.
*/
defaults?: {};
/**
* Name of the config file (without extension).
*/
name?: string;
/**
* Storage file location. *Don't specify this unless absolutely necessary!*
*/
cwd?: string;
}
declare class ElectronStore implements Iterable<[string, string | number | boolean | symbol | {}]> {
constructor(options?: ElectronStoreOptions);
/**
* Sets an item.
*/
set(key: string, value: any): void;
/**
* Sets multiple items at once.
*/
set(object: {}): void;
/**
* Retrieves an item.
*/
get(key: string, defaultValue?: any): any;
/**
* Checks if an item exists.
*/
has(key: string): boolean;
/**
* Deletes an item.
*/
delete(key: string): void;
/**
* Deletes all items.
*/
clear(): void;
/**
* Open the storage file in the user's editor.
*/
openInEditor(): void;
/**
* Gets the item count.
*/
size: number;
/**
* Gets all the config as an object or replace the current config with an object.
*/
store: {};
/**
* Gets the path to the config file.
*/
path: string;
[Symbol.iterator](): Iterator<[string, string | number | boolean | symbol | {}]>;
}
export = ElectronStore;
+22
View File
@@ -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-store-tests.ts"
]
}
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dt.json" ,
"rules": {
"no-namespace":false,
"object-literal-key-quotes": false
}
}