假如你的 Angular 2 代码已经能够在调试环境下正常运行了,可是没法经过 ngc
编译 (或者是一些其余须要编译执行的任务,如 Ionic 2 的 ionic build android
命令等),你会发现一些很是抓狂的错误缘由。android
TypeError: cannot read property 'kind' of undefined
这是一个错误本体和描述没有任何关系的实例,正以下文连接的原回答所说,es6
But unlike other incompatibilities, this one generates the most cryptic error message ever.segmentfault
这个错误的真实缘由是,因为 Angular 的 AoT 的设定不兼容,你不能采用 default exports. 须要使用具名输出。也就是promise
// somefile.ts export default function (...) { ... } ... // some-other-file.ts import whatevar from './somefile';
须要改成angular2
// somefile.ts export function whatevar(...) { ... } ... // some-other-file.ts import { whatevar } from './somefile';
参见问题 http://stackoverflow.com/ques... 最高票答案和评论。ionic
Duplicate identifier 'Promise'
参见以前的问题 https://segmentfault.com/q/10... 。结果代表,不能使用 @types/es6-promise (typings install 我试了一下,貌似也不行,然而不肯定),而应该使用 TypeScript 内建的 Promise 定义。ide
另外 HTML 调用方法时,参数的数量和类型必须和 TypeScript 文件的方法签名一致。ui