Jeremy Danyow Jeremy Danyow - 1 year ago 115
TypeScript Question

TypeScript: @types package name does not match implementation package name

What do you do when the npm package containing the typings does not match the name of the package containing the implementation?

For example,

contains the type definitions for FileSaver.js, whose npm package name is

Background info: the future of declaration files


"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",

Answer Source

In the future, you can git mv the folder in DefinitelyTyped and send us a pull request to the types-2.0 branch (or whichever branch hosts the state of @types). I've done this for you with this pull request.

In the mean time, you can add the "types" field to your tsconfig.json's "compilerOptions" field, and set it to ["filesaver"]. This will tell TypeScript to load in the declaration for you so that you can correctly import file-saver.

Here's an example of how it should look:

    "compilerOptions": {
        // ...
        "types": ["filesaver"]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download