diff --git a/types/storejs/index.d.ts b/types/storejs/index.d.ts index 0a677c0ecf..f720d33617 100644 --- a/types/storejs/index.d.ts +++ b/types/storejs/index.d.ts @@ -15,8 +15,8 @@ interface StoreJsAPI { each(callback: (val: any, namespacedKey: string) => void): void; clearAll(): void; hasNamespace(namespace: string): boolean; - createStore(plugins?: any[], namespace?: string): StoreJsAPI; - addPlugin(plugin: any): void; + createStore(plugins?: Function[], namespace?: string): StoreJsAPI; + addPlugin(plugin: Function): void; namespace(namespace: string): StoreJsAPI; } @@ -33,3 +33,30 @@ declare const engine: StoreJsEngine; declare module 'store/src/store-engine' { export = engine; } +declare module 'store/plugins/all' { + export = Function; +} +declare module 'store/plugins/default' { + export = Function; +} +declare module 'store/plugins/dump' { + export = Function; +} +declare module 'store/plugins/events' { + export = Function; +} +declare module 'store/plugins/expire' { + export = Function; +} +declare module 'store/plugins/observe' { + export = Function; +} +declare module 'store/plugins/operations' { + export = Function; +} +declare module 'store/plugins/update' { + export = Function; +} +declare module 'store/plugins/v1-backcompat' { + export = Function; +} diff --git a/types/storejs/storejs-tests.ts b/types/storejs/storejs-tests.ts index 802f3dd40e..9e631385f5 100644 --- a/types/storejs/storejs-tests.ts +++ b/types/storejs/storejs-tests.ts @@ -1,6 +1,15 @@ // Tests for storagejs.d.ts import * as store from 'store'; import * as engine from 'store/src/store-engine'; +import * as allPlugin from 'store/plugins/all'; +import * as defaultPlugin from 'store/plugins/default'; +import * as dumpPlugin from 'store/plugins/dump'; +import * as eventsPlugin from 'store/plugins/events'; +import * as expirePlugin from 'store/plugins/expire'; +import * as observePlugin from 'store/plugins/observe'; +import * as operationsPlugin from 'store/plugins/operations'; +import * as updatePlugin from 'store/plugins/update'; +import * as v1BackcompatPlugin from 'store/plugins/v1-backcompat'; // https://github.com/marcuswestin/store.js/blob/master/README-More.md#storeenabled-flag console.log('storage is supported: ', store.enabled === true); @@ -52,6 +61,8 @@ store.set('foo', 'bar 1'); store.set('foo', 'bar 2'); store.getHistory('foo'); +store.addPlugin(expirePlugin); + // https://github.com/marcuswestin/store.js/#make-your-own-build // Example custom build usage: @@ -66,9 +77,16 @@ var storages: any[] = [ //require('store/storages/localStorage'), //require('store/storages/cookieStorage') ]; -var plugins: any[] = [ - //require('store/plugins/defaults'), - //require('store/plugins/expire') +var plugins = [ + allPlugin, + defaultPlugin, + dumpPlugin, + eventsPlugin, + expirePlugin, + observePlugin, + operationsPlugin, + updatePlugin, + v1BackcompatPlugin, ]; var myStore = engine.createStore(storages, plugins); myStore.set('foo', 'bar', new Date().getTime() + 3000); // Using expire plugin to expire in 3 seconds