diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index e3e3343095..3907696d6b 100644 --- a/localForage/localForage-tests.ts +++ b/localForage/localForage-tests.ts @@ -61,8 +61,7 @@ namespace LocalForageTest { localForage.removeItem("key").then(() => { }); - localForage.getDriver("CustomDriver").then((result: LocalForageDriver) => { - var driver: LocalForageDriver = result; + localForage.getDriver("CustomDriver").then((driver: LocalForageDriver) => { // we need to use a variable for proper type guards before TS 2.0 var _support = driver._support; if (typeof _support === "function") { @@ -105,4 +104,13 @@ namespace LocalForageTest { testSerializer = serializer; }); } -} \ No newline at end of file + + { + let store: LocalForage; + + store.ready() + .then(() => {}); + + store.ready(() => {}); + } +} diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index e5d42d6d12..bf4f621652 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -41,7 +41,7 @@ interface LocalForageDbMethods { iterate(iteratee: (value: any, key: string, iterationNumber: number) => any): Promise; iterate(iteratee: (value: any, key: string, iterationNumber: number) => any, - callback: (err: any, result: any) => void): void; + callback: (err: any, result: any) => void): void; } interface LocalForageDriverSupportFunc { @@ -53,11 +53,11 @@ interface LocalForageDriver extends LocalForageDbMethods { _initStorage(options: LocalForageOptions): void; - _support: boolean | LocalForageDriverSupportFunc; + _support?: boolean | LocalForageDriverSupportFunc; } interface LocalForageSerializer { - serialize(value: T | ArrayBuffer | Blob, callback: (value: string, error: any) => {}): void; + serialize(value: T | ArrayBuffer | Blob, callback: (value: string, error: any) => void): void; deserialize(value: string): T | ArrayBuffer | Blob; @@ -72,10 +72,10 @@ interface LocalForage extends LocalForageDbMethods { INDEXEDDB: string; /** - * Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded. - * If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver() - * @param {ILocalForageConfig} options? - */ + * Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded. + * If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver() + * @param {LocalForageOptions} options? + */ config(options: LocalForageOptions): boolean; /** @@ -87,23 +87,26 @@ interface LocalForage extends LocalForageDbMethods { driver(): string; /** - * Force usage of a particular driver or drivers, if available. - * @param {string} driver - */ + * Force usage of a particular driver or drivers, if available. + * @param {string} driver + */ setDriver(driver: string | string[]): Promise; setDriver(driver: string | string[], callback: () => void, errorCallback: (error: any) => void): void; defineDriver(driver: LocalForageDriver): Promise; defineDriver(driver: LocalForageDriver, callback: () => void, errorCallback: (error: any) => void): void; /** - * Return a particular driver - * @param {string} driver - */ + * Return a particular driver + * @param {string} driver + */ getDriver(driver: string): Promise; getSerializer(): Promise; getSerializer(callback: (serializer: LocalForageSerializer) => void): void; supports(driverName: string): boolean; + + ready(callback: () => void): void; + ready(): Promise; } declare module "localforage" { diff --git a/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts b/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts index d6a9ac4ae2..c3d35b710b 100644 --- a/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts +++ b/localforage-cordovasqlitedriver/localforage-cordovasqlitedriver-tests.ts @@ -36,7 +36,7 @@ declare var cordovaSQLiteDriver: LocalForageDriver; var newError: any = err; var newStr: string = str }); - + cordovaSQLiteDriver.setItem("key", "value", (err: any, str: string) => { var newError: any = err; var newStr: string = str @@ -45,7 +45,7 @@ declare var cordovaSQLiteDriver: LocalForageDriver; cordovaSQLiteDriver.setItem("key", "value", (str: string) => { var newStr: string = str; }); - + cordovaSQLiteDriver.removeItem("key",(err: any) => { var newError: any = err; }); @@ -53,4 +53,4 @@ declare var cordovaSQLiteDriver: LocalForageDriver; cordovaSQLiteDriver.removeItem("key", (err: any) => { var newError: any = err; }); -} \ No newline at end of file +}