apache / couchdb-nano

Nano: The official Apache CouchDB library for Node.js
https://www.npmjs.com/package/nano
Apache License 2.0
653 stars 165 forks source link

Exposing Types for TypeScript #339

Open digimbyte opened 10 months ago

digimbyte commented 10 months ago

Typings for Nano are not exposed or able to import through TypeScript

Expected Behavior

being able to define types and add Nano.ServerScope as a typings to my objects and functions const NanoInstances = new Map<string,Nano.ServerScope>();

Current Behavior

instead, we have to create a dummy instance to localhost and extract the reference as follows

    const nanoInstance = Nano('http://localhost:5894');
    type NanoType = typeof nanoInstance;

    // Now you can use NanoType to reference the typings
    const NanoServers = new Map<string, NanoType>();

    function findDoc (instance: NanoType, doc: string){
        //...
    }

Possible Solution

just need to expose the types through an entry point or export them directly

Context

I am building a modular platform that allows multiple Nano instances to be present and are configured dynamically. since we are using strict type safety, its better to use the correct typing's vs any or unknown

Your Environment