您现在的位置:首页 >> 前端 >> 内容

grunt-ts编译成es5报错

时间:2017/5/5 17:01:00 点击:

  核心提示:grunt-ts编译成es5报错。报错信息如下node_modules/@angular/core/src/application_init.d.ts(17,27): error TS2304: Ca...

grunt-ts编译成es5报错。报错信息如下

node_modules/@angular/core/src/application_init.d.ts(17,27): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(116,76): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(132,110): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(162,67): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(164,101): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,16): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(32,16): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts(15,48): error TS2304: Cannot find name 'Iterable'.
node_modules/@angular/core/src/change_detection/differs/keyvalue_differs.d.ts(23,18): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,123): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,165): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/linker/compiler.d.ts(43,49): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/compiler.d.ts(51,65): error TS2304: Cannot find name 'Promise'.
主要意思说是map,promise找不到,这2个对象是es6才有的,如果改成编译成es6,就不报错。

 

查找了很多资料,也试了很多方法。

最终

target: "es5", //es3 for IE8 and below
              lib: ["es2016", "dom"], //加上这个就可以解决该问题

Tags:GR RU UN NT 
作者:网络 来源:danielinbi