使用带有 RC5 的 Angular2 AoT ngc 编译器获取 `Cannot read property 'type' of null` [英] Get `Cannot read property 'type' of null` using Angular2 AoT ngc compiler with RC5

查看:17
本文介绍了使用带有 RC5 的 Angular2 AoT ngc 编译器获取 `Cannot read property 'type' of null`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到 Angular2 2.0.0-rc.5,在浏览器中运行没有任何警告,但是当尝试使用 ngc -p 命令进行 AOT 编译时,得到流动错误:

Update to Angular2 2.0.0-rc.5, run in browser without any warning, but when try AOT compile with ngc -p command, get the flowing error:

这是我的项目 https://github.com/beginor/learning-angular2

推荐答案

不要在代码中使用默认导出:

Do not use default exports in your code:

// somefile.ts
export default function (...) {
    ...
}
...
// some-other-file.ts
import whatevar from './somefile';

改用显式名称

// somefile.ts
export function whatevar(...) {
    ...
}
...
// some-other-file.ts
import { whatevar } from './somefile';

AOT 与默认导出(除其他外)不兼容.但与其他不兼容问题不同的是,这个不兼容问题会产生有史以来最神秘的错误消息.

AOT is incompatible with default exports (among other things). But unlike other incompatibilities, this one generates the most cryptic error message ever.

这篇关于使用带有 RC5 的 Angular2 AoT ngc 编译器获取 `Cannot read property 'type' of null`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆