Shikha
Shikha

Reputation: 551

How to use lodash function in angular 5 project?

I want to use merge function from lodash. If I am including whole lodash , it increases bundle size . So I am trying to use function from lodash. But it is giving error.

import { merge } from 'lodash/merge';

or

  import merge from 'lodash/merge';

Can anyone suggest me how to use this in angular 5 application ? I have installed following versions:

 "lodash": "^4.17.5",
  "@types/lodash": "^4.14.104"

Upvotes: 2

Views: 2083

Answers (2)

Shikha
Shikha

Reputation: 551

import * as merge from 'lodash/fp/merge'; worked fine

Upvotes: 4

Koushik Chatterjee
Koushik Chatterjee

Reputation: 4175

You can still do any JS way of things in TS (since it's a super-set)

Try with:

import merge = require('lodash/merge');

Upvotes: 1

Related Questions