likerRr likerRr - 1 month ago 8
TypeScript Question

Where to get @types for single lodash package?

I need one function from lodash - assignin. I installed

lodash.assignin
and imported it in my project:

import assignIn = require('lodash.assignin');


But after compilation there is an error: "error TS2307: Cannot find module 'lodash.assignin'".

I understand that I need typings for
lodash.assignin
package, but unfortunately there is only
lodash/assignin
type in
@types/lodash
.

I don't want install whole lodash package for just one of its function, so does lodash have typings for their single packages?

Answer

That package (lodash.assignin) is not available, please check list of available lodash packages here https://www.npmjs.com/browse/keyword/lodash-modularized

For example if I want to use the first method I need to install npm i --save lodash.first Then I use the method like this const first = require('lodash.first');