How to Solve Typescript errors on @types\lodash\index.d.ts

  • Posted on: 8 January 2018
  • By: jmu

How to solve Typescript errors on @types\lodash\index.d.ts? 

I got lots of errors after I run npm install. And I already have "@types/lodash: 4.14.50" in my package.json. However, it doesn't work at all.

Here is the error sample I got:

C:folder/node_modules/@types/lodash/index.d.ts (16807,33): Cannot find name 'Many'.
C:folder/node_modules/@types/lodash/index.d.ts (16820,43): Cannot find name 'Many'.
C:folder/node_modules/@types/lodash/index.d.ts (16827,43): Cannot find name 'Many'.
C:folder/@types/lodash/index.d.ts (16945,20): Cannot find name 'object'.
C:folder/node_modules/@types/lodash/index.d.ts (17021,20): Cannot find name 'object'.
C:folder/node_modules/@types/lodash/index.d.ts (17053,32): Cannot find name 'object'.
C:folder/node_modules/@types/lodash/index.d.ts (17300,79): Cannot find name 'object'.
C:folder/node_modules/@types/lodash/index.d.ts (17304,46): A parameter initializer is only allowed in a function or cons
tructor implementation.

C:folder/node_modules/@types/lodash/index.d.ts (17354,10): Cannot find name 'P'.
C:folder/node_modules/@types/lodash/index.d.ts (17354,15): Cannot find name 'keyof'.
C:folder/node_modules/@types/lodash/index.d.ts (17354,21): Cannot find name 'T'.
C:folder/node_modules/@types/lodash/index.d.ts (17354,26): Cannot find name 'PartialDeep'.
C:folder/node_modules/@types/lodash/index.d.ts (17354,38): Cannot find name 'T'.
C:folder/node_modules/@types/lodash/index.d.ts (17354,40): Cannot find name 'P'.

The way to solve this is using npm install --save @types/lodash@4.14.50 to install lodash, then the errors are all gone. 

English