Skip to content

Instantly share code, notes, and snippets.

@ahomu
Created May 11, 2015 11:22
Show Gist options
  • Save ahomu/3ea1877a49ddf25d7f7f to your computer and use it in GitHub Desktop.
Save ahomu/3ea1877a49ddf25d7f7f to your computer and use it in GitHub Desktop.
ふむーん
src/shared/idb-store-base.ts(3,29): error TS2497: External module ''idb-wrapper'' resolves to a non-module entity and cannot be imported using this construct.
/**
* IDBWrapper
*/
declare class IDBWrapper {
constructor(options: any);
put(dataObj: any, success?: (id: string) => void, error?: Function): void;
}
declare module IDBWrapper {
}
declare module 'idb-wrapper' {
export = IDBWrapper;
}
// // class 実装の宣言
// declare class IDBWrapper {
// constructor(options: any);
// put(dataObj: any, success?: (id: string) => void, error?: Function): void;
// }
// // 公開 module の 宣言
// declare module 'idb-wrapper' {
// export = IDBWrapper;
// }
// // 公開 module の 宣言
// declare module 'idb-wrapper' {
// export = IDBWrapper;
// // globalに名前をまき散らしたくなかったら(commonjsオンリーなら)declare moduleの内側に入れる
// class IDBWrapper {
// constructor(options: any);
// put(dataObj: any, success?: (id: string) => void, error?: Function): void;
// }
// }
///<reference path="../common.d.ts" />
import * as IDBWrapper from 'idb-wrapper';
import * as Rx from 'rx';
export default class IDBStoreBase<T> {
store: IDBWrapper;
open() {
this.store = new IDBWrapper(this);
}
put(dataObj: T): Rx.Subject<string> {
let subject: Rx.Subject<string> = new Rx.Subject<string>();
this.store.put(dataObj, (id)=> {
subject.onNext(id);
subject.onCompleted();
}, (error) => {
subject.onError(error);
subject.onCompleted();
});
return subject;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment