UPDATE localForage typings

This commit is contained in:
recuedav
2016-11-02 11:34:49 +01:00
parent 1c98e17b07
commit 20aff2bdb6
3 changed files with 20 additions and 9 deletions

View File

@@ -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;
});
}
{
let store: LocalForage;
store.ready()
.then(() => {});
store.ready(() => {});
}
}

View File

@@ -41,7 +41,7 @@ interface LocalForageDbMethods {
iterate(iteratee: (value: any, key: string, iterationNumber: number) => any): Promise<any>;
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<T>(value: T | ArrayBuffer | Blob, callback: (value: string, error: any) => {}): void;
serialize<T>(value: T | ArrayBuffer | Blob, callback: (value: string, error: any) => void): void;
deserialize<T>(value: string): T | ArrayBuffer | Blob;
@@ -74,7 +74,7 @@ interface LocalForage extends LocalForageDbMethods {
/**
* 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?
* @param {LocalForageOptions} options?
*/
config(options: LocalForageOptions): boolean;
@@ -104,6 +104,9 @@ interface LocalForage extends LocalForageDbMethods {
getSerializer(callback: (serializer: LocalForageSerializer) => void): void;
supports(driverName: string): boolean;
ready(callback: () => void): void;
ready(): Promise<void>;
}
declare module "localforage" {

View File

@@ -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;
});
}
}