我有一个讨厌的要求来支持IE11,所以我正在尝试配置一个项目来编译ES-5。
这是我的tsconfig.json
:
{
"compileOnSave": false,
"compilerOptions": {
"target":"es5",
"module":"commonjs",
"moduleResolution": "node",
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false
}
}
这是我的polyfils.ts
:
import 'core-js/es6';
// import { enableProdMode } from '@angular/core';
import 'ts-helpers';
import 'zone.js';
if (process.env.NODE_ENV === 'production') {
// Production
// enableProdMode();
} else {
// Development
require('zone.js/dist/long-stack-trace-zone');
Error['stackTraceLimit'] = Infinity;
}
正如您所看到的,我为es6导入了垫片的core-js,但是当我尝试使用webpack进行编译时,我得到了下一个错误:
@angular\core\src\change_detection\differs\default_keyvalue_differ.d.ts
(24,16): error TS2304: Cannot find name 'Map'.
rxjs\Observable.d.ts
(58,60): error TS2693: 'Promise' only refers to a type, but is being used as a value here.
@angular\common\src\directives\ng_class.d.ts
(48,34): error TS2304: Cannot find name 'Set'.
感谢您的帮助。