How to avoid problems introduced by @types packages with patch level increase that introduces breaking change?

2.8k views Asked by At

I realized that a Jenkins build of our Angular app is broken. We got the following error message.:

ERROR in node_modules/angular2-hotkeys/lib/hotkeys.service.d.ts:9:16 - error TS2304: Cannot find name 'MousetrapInstance'.

9     mousetrap: MousetrapInstance;
                 ~~~~~~~~~~~~~~~~~

Then problem is the following breaking change in @types/mousetrap from:

export const mousetrap: MousetrapInstance;

to:

export const mousetrap: Mousetrap.MousetrapInstance;

In angular2-hotkeys package.json, the dependencies are defined as follows:

"dependencies": {
     "mousetrap": "^1.6.0",
     "@types/mousetrap": "^1.6.0"
 },

What is the correct NPM way to avoid this version problem?

1

There are 1 answers

0
Stéphane Veyret On

You cannot guarantee the package version used with package.json, even if you specify an exact match (without the ^) because there may be dependencies requiring another version.

The only way to be sure that the version in your computer, and the version in the CI are the same is to also commit the package-lock.json file.