使用带有 RC5 的 Angular2 AoT ngc 编译器获取 `Cannot read property 'type' of null`

编程入门 行业动态 更新时间:2024-10-28 15:25:38
本文介绍了使用带有 RC5 的 Angular2 AoT ngc 编译器获取 `Cannot read property 'type' of null`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

更新到 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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 00:23:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1031211.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编译器   AoT   ngc   null   type

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!