Where to get @types for single lodash package?

Multi tool use


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:
lodash.assignin
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
.
lodash.assignin
lodash/assignin
@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?
lodash.assignin
lodash.assign
@JaganathanBantheswaran sorry, what do you mean? npmjs.com/package/lodash.assignin
– likerRr
Oct 18 '16 at 12:25
2 Answers
2
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');
first
npm i --save lodash.first
const first = require('lodash.first');
What do you mean it's not available? It's the same as other packages github.com/lodash/lodash/tree/4.2.0-npm-packages
– likerRr
Oct 18 '16 at 13:28
Anyway, syntax
const assignIn = require('lodash.assignin')
works well for me, despite it is mostly node-like variant.– likerRr
Oct 18 '16 at 13:34
const assignIn = require('lodash.assignin')
You are right, it is available. I think you are not installing the package correctly since I have tested locally and it works. Did you do
npm i --save lodash.assignin
?– Cristian Penarrieta
Oct 18 '16 at 13:35
npm i --save lodash.assignin
You cannot use
import
in node.js yet– Cristian Penarrieta
Oct 18 '16 at 13:36
import
I'm saying that using
require
is node style to import modules. In typescript it's preferred to use word import
.– likerRr
Oct 18 '16 at 13:37
require
import
I just solved this for a different package with the following:
src/types/lodash.groupby.d.ts:
import { groupBy } from 'lodash'
export default groupBy
yarn add -D '@types/lodash@^4.6.0'
yarn add -D '@types/lodash@^4.6.0'
Then import with:
import groupBy from 'lodash.groupby'
This is using TypeScript 2.9.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Its not
lodash.assignin
butlodash.assign
– Thaadikkaaran
Oct 18 '16 at 12:22