From 1f88c485c472c7addcf5d24f69b19a2c0ae6a54a Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Tue, 15 Sep 2015 23:23:06 +0200 Subject: [PATCH] improved localforage to use default exports (the way it usually should be imported) --- localForage/localForage-tests.ts | 10 +++++----- localForage/localForage.d.ts | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts index ae1f03419..1ba6611d3 100644 --- a/localForage/localForage-tests.ts +++ b/localForage/localForage-tests.ts @@ -1,6 +1,6 @@ /// -import * as localForage from "localforage"; +import {default as localForage} from "localforage"; () => { localForage.clear((err: any) => { @@ -63,13 +63,13 @@ import * as localForage from "localforage"; }); - var config = localForage.default.config({ + var config = localForage.config({ name: "testyo", - driver: localForage.default.LOCALSTORAGE + driver: localForage.LOCALSTORAGE }); - var store = localForage.default.createInstance({ + var store = localForage.createInstance({ name: "da instance", - driver: localForage.default.LOCALSTORAGE + driver: localForage.LOCALSTORAGE }); } diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index cd1ee1d33..9adb9ca1d 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -7,8 +7,7 @@ declare module lf { - interface ILocalForage { - default: ILocalForageStatic; + interface ILocalForage extends ILocalForageStatic { /** * Removes every key from the database, returning it to a blank slate. */ @@ -52,9 +51,18 @@ declare module lf { LOCALSTORAGE: string; WEBSQL: 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? + */ config(options?: ILocalForageConfig): boolean; createInstance(options?: ILocalForageConfig): ILocalForage; defineDriver(driverObject?: any): void; + /** + * Force usage of a particular driver or drivers, if available. + * @param {string} driver + */ setDriver(driver: string): void; supports(driverName: string): boolean; } @@ -94,6 +102,6 @@ declare module lf { } declare module "localforage" { - var tmp: lf.ILocalForage; - export = tmp; + var localforage: lf.ILocalForage; + export default localforage; } \ No newline at end of file