使用traceur和SystemJS使用ES6这种形式是正确的:
import _ from 'lodash';@H_403_3@对于Typescript它是不够的 – 我得到错误错误TS2307:找不到模块’lodash’所以,我安装’lodash.d.ts’:
/// <reference path="lodash/lodash.d.ts" /> import _ from 'lodash';@H_403_3@现在,我得到:模块’“lodash”’没有默认导出.来自Typescript编译器 @H_403_3@所以,我尝试’节点样式’:
/// <reference path="lodash/lodash.d.ts" /> let _ = require('lodash');@H_403_3@我得到:未捕获(在承诺中)错误:require不是浏览器中的函数 @H_403_3@最后:
import _ = require('lodash');@H_403_3@并且它有效,但它的’旧形式’不适合ES6. @H_403_3@对于非打字稿模块,是否有单一,正确的方法来使用ES6样式的Typescript导入? @H_403_3@(打字稿1.6.2)
尝试从’lodash’导入*作为_;