question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: collate different sources

See original GitHub issue

Hi! I’m currently working on PouchDB wrappers. But my currrent knowledge on both Typescript and F# limits what I can do.

My current issue is that I have types for PouchDB that are registered like this in an index.d.ts file:

/// <reference types='pouchdb-adapter-fruitdown' />
/// <reference types='pouchdb-adapter-http' />
/// <reference types='pouchdb-adapter-idb' />
/// <reference types='pouchdb-adapter-leveldb' />
/// <reference types='pouchdb-adapter-localstorage' />
/// <reference types='pouchdb-adapter-memory' />
/// <reference types='pouchdb-adapter-node-websql' />
/// <reference types='pouchdb-adapter-websql' />
/// <reference types='pouchdb-browser' />
/// <reference types='pouchdb-core' />
/// <reference types='pouchdb-http' />
/// <reference types='pouchdb-mapreduce' />
/// <reference types='pouchdb-node' />
/// <reference types='pouchdb-replication' />
declare const plugin: PouchDB.Static;
export = plugin;

So as you can see, pouchdb seems to have many sub-repositories.

I got every d.ts file and tried to export them to F# using ts2fable. However, there is a Database typescript inteface that is updated from many files. So that in the end we’ve got this big database interface merged from all these sources. (that is, if I understand well the process)

interface Database<Content extends {} = {}> {...}

The same thing goes with PouchDB plugins which updates this Database interface as well. For instance the pouchd-find plugin adds a find method to the interface.

So currently here’s my process:

  1. I export every ts file individually
  2. I copy and paste the code into my Fable.Import.PouchDB.fs file
  3. I manually merge the Database interface

There’s another element in charge here: the Database interface is never actually transpiled to F#.

This thing:

    interface Database<Content extends {} = {}> {
        viewCleanup(callback: Core.Callback<Core.BasicResponse>): void;

        viewCleanup(): Promise<Core.BasicResponse>;

        query<Result, Model = Content>(fun: string | Map<Model, Result> | Filter<Model, Result>, opts: Query.Options<Model, Result>, callback: Core.Callback<Query.Response<Result>>): void;

        query<Result, Model = Content>(fun: string | Map<Model, Result> | Filter<Model, Result>, callback: Core.Callback<Query.Response<Result>>): void;

        query<Result, Model = Content>(fun: string | Map<Model, Result> | Filter<Model, Result>, opts?: Query.Options<Model, Result>): Promise<Query.Response<Result>>;
    }

becomes:

    type [<AllowNullLiteral>] Database<'Content> =
        interface end

But let’s say that eventually this will work. Will I be able to just merge the Database interface automatically? Is it already possible?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ctaggartcommented, Dec 20, 2017

I think issue #128 and pr #145 are related. When I get back to ts2fable development, reviewing that pr and these use cases are on my todo list.

0reactions
whitetiglecommented, Mar 27, 2018

the module PouchDB.Core seems to be written many times (4 times): image

And the module PouchDB is written 11 times. So can it be some redefinitions in ts submodules not handled correcty?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Collating Different Evidence Types - Peer Connect
What types of evidence gathering tools are you planning to use in your planned evaluation? If this includes a survey, what types of...
Read more >
Practical guidance for using multiple data sources in ... - NCBI
Data for individual trials included in systematic reviews may be available in multiple sources. For example, a single trial might be reported in...
Read more >
Merging Data from Multiple Sources - Challenges and ...
When it comes to deriving insights from data, it becomes important to combine all data sources and get one single point of reference....
Read more >
8 Questions To Ask When Combining Multiple Data Sources
A checklist to help you accurately link syndicated data from Nielsen/IRI with info from other sources + a simple example using retailer ...
Read more >
Combining Responses
If necessary, you can combine response data from 2 surveys. The steps differ depending on whether you are combining data from 2 identical...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found