with ES6 using traceur and SystemJS this form is correct:
import _ from 'lodash';
for Typescript it is not enough - I get error error TS2307: Cannot find module 'lodash'
So, I install 'lodash.d.ts' :
/// <reference path="lodash/lodash.d.ts" />
import _ from 'lodash';
Now, I get: Module '"lodash"' has no default export.
from Typescript compiler
So, I try 'node style':
/// <reference path="lodash/lodash.d.ts" />
let _ = require('lodash');
I get: Uncaught (in promise) Error: require is not a function
in browser
Finally:
import _ = require('lodash');
and it works but it's 'old form' not proper ES6.
Is there a single, proper way to use ES6 style Typescript import for non-typescript modules?
(Typescript 1.6.2)
Try import * as _ from 'lodash';
if you import lodash as node_module, you might need to do it as declare var _: any;
if you wanna do import * as _ from 'lodash', then import loadash thru TypeScript Definition manager (tsd). in terminal, do it as
tsd install lodash --save
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