apache / couchdb-nano

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

Missing optional in requestDefaultsOptions type definition #247

Closed crystalfp closed 3 years ago

crystalfp commented 3 years ago

When I use nano from typescript I cannot specify, for example, only timeout. I should specify all three timeout, agent, headers or not use requestDefaults at all.

Expected Behavior

In a previous version (8?) the following code was valid:

        const nano = Nano({
            url: databaseURL,
            requestDefaults: {timeout: 60000}
        });

Current Behavior

The call generates the following error message during typescript compilation:

Type '{ timeout: any; }' is missing the following properties from type 'requestDefaultsOptions': agent, headers ts(2739)

Possible Solution

In nano.d.ts change the interface requestDefaultsOptions to:

  interface requestDefaultsOptions {
    timeout?: number;
    agent?: any;
    headers?: object;
  }

Steps to Reproduce (for bugs)

  1. Create a bug.ts file containing import Nano from "nano"; and the Nano instantiation above.
  2. Put anything as databaseURL
  3. Compile it
  4. Look at the error being generated

Context

I simply don't specify a timeout hoping for the best.

Your Environment

crystalfp commented 3 years ago

Fixed in nano 9.0.2! Thanks!