Michael Michael - 6 months ago 17
Node.js Question

Incorrect TypeScript definition for request / request-promise: option "time" is missing

On NodeJS with TypeScript and using npm request-promise (which wraps npm request).

I want to use the "time" option to time the round-trip as documented here "time - If true, the request-response cycle (including all redirects) is timed at millisecond resolution, and the result provided on the response's elapsedTime property" and which is available within the npm as evidenced here

if (options.time) {
self.timing = true
self.elapsedTime = self.elapsedTime || 0
}


But this option doesn't appear to be supported in any of the request definitions I can find.

So my first question is - am I reading things wrong?

If not, my second question is - is there a reason it's not there?

Finally, if it should be there - I can modify my local copy of the definitions but, of course, the better way is to get the repository definitions fixed and I'm just not exactly sure the best way to go about doing that, so who can point me in the right direction?

pyc pyc
Answer

The definition for the time option is missing from the typings definition of the request package: https://github.com/louy/typed-request/blob/master/index.d.ts

The typings definition are for version 2.69 of the request package (https://github.com/typings/registry/blob/master/npm/request.json) which probably didn't have that time option

To get the repository definition fixed, you can ask the author of the type-request repository to fix it, or you can fork the main repository, do your updates and issue a pull request to the original author. In the mean time, you can still install the definitions you updated into your project with:

typings install --save github:<YourGithubUsername>/<RepositoryName>#<CommitSha>