With es6, I can import just one function from a library to minimise the whole bundle, like:
import merge from "lodash/merge"
However, in typescript, the above sentence will cause a compile error: Cannot find module "lodash/merge". How to solve it?
Actually you can import a single function using the 'lodash.merge'
library
import merge from 'lodash.merge'
const result: any = merge(obj1, obj2)
BUT
You need to add this property to the tsconfig.json "esModuleInterop": true
without this it will not work
[cit] https://github.com/lodash/lodash/issues/3192#issuecomment-411963038
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With