mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-23 04:47:24 +08:00
UPDATE localForage typings
This commit is contained in:
@@ -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(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
11
localForage/localForage.d.ts
vendored
11
localForage/localForage.d.ts
vendored
@@ -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" {
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user