2016-09-27 67 views
1

有没有人有使用ES6的快速入门教程(https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html)的工作示例?基本上,我想这样做:Angular 2快速入门VS 2015与ES6

typings.config(强调ES6):

{ 
"compilerOptions": { 
    "target": "es6", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
} 

}

当我做到这一点,编译,我得到了核壳式两份声明错误JS是这样的:

<path>\typings\globals\core-js\index.d.ts(3,14): error TS2300: Build:Duplicate identifier 'PropertyKey'. 

如果我删除核心JS,我可以得到它来编译,但它不会在IE11工作(在边缘,FF和铬作品)。如果我将它改为es5,它也可以在IE11中使用。我正在使用最新版本的TypeScript(2.0)

有人可以解释我做错了什么吗?提前致谢。

回答

1

看起来像以下更改将使项目在构建es6时毫无错误地生成。

添加下列排除到tsconfig.js(核心JS是这里最重要的一个):

{ 
"compilerOptions": { 
    "target": "es6", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
}, 
"compileOnSave": true, 
"exclude": [ 
    "node_modules", 
    "typings/index.d.ts", 
    "typings/globals/core-js" 
] 

}

安装茉莉分型,以获得规范编译:

typings install dt~jasmine --global --save 

此外,该指南并未提及从起始项目中复制systemjs.config.js

+0

感谢您回复杰伊。我有它编译。但是,它在IE中不起作用。我得到这样的脚本错误:{description:“(SystemJS)...”,message:“(SystemJS)...”,name:“Error”,originalErr:Error {...},stack:“(SystemJS )...“,符号(rxSubscriber)_m.n7ipu3mz39j:undefined} – Hari

+0

@ user3434332你是否得到这个工作。我也面临这个问题 – sskasim

+0

对不起@sskasim,我没有看过这一段时间..转移到一个不同的项目。我必须在某个时候回到这个位置。我希望当时所有的问题都会消失! – Hari