by barake · 9y ago · 0 comments
import flatten = require('lodash/flatten')
TS expects any modules imported using ES2015 import to have the shape of a ES2015 module. This is an issue for many UMD/commonjs modules. In the case of lodash, it's effectively doing this: module.exports = flatten
And then you're importing it like so: import flatten from 'lodash/flatten'
and that is being transpiled to something like: var flatten = require('lodash/flatten').default
Note the default.I haven't migrated to webpack 2, but some brief experiments suggest all modules get massaged in to ES2015 format.
So far (a bit unexpectedly) I didn't really run into any nasty side-effects or things that went wrong with it.
See https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in... for a (short) explanation.