Reputation: 4622
I cannot compile my angular 2 application when set to es5 in the tsconfig.json file. If i change it to es6 all my compiler errors disappear.
tsconfig:
"compilerOptions": {
"target": "es5",
"module": "system",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"moduleResolution": "node"
},
"files": [ ...
Index.html
<script src="~/node_modules/systemjs/dist/system.src.js"></script>
<script src="~/node_modules/es6-shim/es6-shim.min.js"></script>
<script src="~/node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="~/node_modules/moment/min/moment.min.js"></script>
<script>
System.config({
defaultJSExtensions: true,
baseURL: '/ECAV.Admin/node_modules',
packages: {
'app': { format: 'register', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' }
},
paths: {
'angular2/*': 'angular2/*',
'rxjs': 'rxjs/bundles/Rx.js',
'linqsharp': 'linqsharp/built/linqsharp',
'highcharts': 'highcharts',
'ng2-highcharts': 'ng2-highcharts/ng2-highcharts',
'lodash': 'lodash/lodash'
},
map: {
moment: 'moment/moment.js'
}
});
</script>
<script src="/Admin/node_modules/rxjs/bundles/Rx.js"></script>
<script src="/Admin/node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="/Admin/node_modules/lodash/lodash.js"></script>
Example error (there are many of these from library classes):
Build: Cannot find name 'Set'. Admin C:\dev\ecav\Admin\node_modules\angular2\src\common\directives\ng_class.d.ts 72
One of my requirments is to run this website in IE11, so I need es5.
Any help would be much appreciated.
Upvotes: 2
Views: 584
Reputation: 1223
If you are transpiling to ES5 you may need to set ///<reference path="node_modules/angular2/typings/browser.d.ts"/>
in your main typescript file.
From: https://stackoverflow.com/a/35737470/3279156
Upvotes: 2