pouchdb-community/relational-pouch

typescript support ?

Opened this issue · 6 comments

I'm trying to figure out how to use it with typescript, seems people get it working for pouchdb-find.

https://github.com/nolanlawson/pouchdb-find/issues/201

It seems we can do the same fix for relational-pouch but can we test is? I don't know typescript. Can you test it?

I'm newbie for typings. Since I am using angular2 cli, they have a build system, what I did is to put

    declare module 'relational-pouch';

in typings.d.ts under src. And then in your own file reference them as.

    import * as PouchDB from 'pouchdb';
    import * as Relational from 'relational-pouch';
    PouchDB.plugin(Relational);

I did import pouchdb typings, so that one has no issue. Once i declare the module, seems everything is fine to me. I'm using it now. If I need to do createIndex, I'll have to do the same thing with package pouchdb-find.

In short, I didn't use the approach outlined in above thread. Of course angular2 cli build might be doing its own thing.

Looks good! Can this issue be closed?

I am facing issues while including it in typescript. ANy help will be greatly appreciated.

Promise.resolve is not a function error

Facing this save issue, doing the steps suggested by @windmaomao. THe compiler complains about the import * as PouchDB from 'pouchdb'; throwing a warning:

55:8-22 "export 'plugin' (imported as 'PouchDB') was not found in 'pouchdb'

This compiles at the very least:

import PouchDB from 'pouchdb';
import * as Relational from 'relational-pouch';
PouchDB.plugin(Relational); // in constructor

I found this is the only way to get it to compile correctly but then I get the Promise.resolve is not a function error.