typescriptnpmtypescript-definitions

Where do Typescript Node Module Implementations live


So I am writing an application using Typescript. I am using the following library;

https://www.npmjs.com/package/@types/request

So I ran npm install --save @types/request and decided to inspect my node_modules folder. In it I can see the request library with these files:

In typescript, files that end with .d.ts are definition files, where implementation does not exist.

When I actually write my code, I am able to import from this library and use it's API just fine. But where does the implementation for this API actually live, it does not appear to exist.


Solution

  • In the request NPM package: https://github.com/request/request. The @types/request package is only TypeScript definitions for it. If a package itself does not have TypeScript definitions, TypeScript will look for them in @types/packageName.

    npm i --save request
    
    import * as request from 'request'