Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing Types for TypeScript #339

Open
digimbyte opened this issue Jan 17, 2024 · 0 comments
Open

Exposing Types for TypeScript #339

digimbyte opened this issue Jan 17, 2024 · 0 comments

Comments

@digimbyte
Copy link

digimbyte commented Jan 17, 2024

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

  • Version used: "nano": "^10.1.3",
  • Browser Name and version: node v18.17.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant