简体   繁体   中英

How to use @types/lodash for the individual lodash.* libraries

In an effort to reduce the bundle size of my Angular project I am installing and importing individual lodash libraries. ie. lodash.clonedeep and other lodash.* but lose type definitions for these as the they do not work with the @types/lodash npm package.

I have tried to google around and find a way to alias the type definitions but haven't found anything for that.

const cloneDeep = require('lodash.clonedeep');
import { cloneDeep } from 'lodash';

The first does not give me type information in my IDE where the second does as it uses @types/lodash.

You don't have to use the whole @types/lodash package for the individual lodash packages. Mostly, in all the cases you can get type definitions for the lodash individual packages.

For lodash.clonedeep , you can get @types/lodash.clonedeep from npm registry

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM