Question: collate different sources
See original GitHub issueHi! 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:
- I export every ts file individually
- I copy and paste the code into my Fable.Import.PouchDB.fs file
- 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:
- Created 6 years ago
- Comments:10 (4 by maintainers)
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.
the module PouchDB.Core seems to be written many times (4 times):
And the module PouchDB is written 11 times. So can it be some redefinitions in ts submodules not handled correcty?