首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么是x.ngfactory.ts文件,以及如何在使用@角/cli 1.1.1时调试这些文件?

什么是x.ngfactory.ts文件,以及如何在使用@角/cli 1.1.1时调试这些文件?
EN

Stack Overflow用户
提问于 2017-06-11 14:13:34
回答 1查看 1.8K关注 0票数 0

我用的是角4.x,webpack 2.x,打字本2.x。

我正在使用@ar角/cli构建我的项目。

但是,当我执行ng serve时,它工作得很好,所有的代码都被成功地转换了,并且在视图中运行得非常好。

其日志如下:

代码语言:javascript
复制
webpack: Compiling...
Hash: 24b7c2a082104ba0df53                                                         
Time: 9187ms
chunk    {0} main.bundle.js, main.bundle.js.map (main) 661 kB {3} [initial] [rendered]
chunk    {1} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 285 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.69 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]
webpack: Compiled successfully.

但是,当我执行ng build --prod时,它会抛出以下几个错误:

代码语言:javascript
复制
ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/people/people.component.ngfactory.ts (1292,11): Type 'MProfile | IConversationProfile' is not assignable to
type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/conversation/conv.component.ngfactory.ts (950,11): Type 'MProfile | IConversationProfile' is not assignable
to type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/local_node_modules/ngx-uploader/src/module/ngx-uploader.module.ngfactory.ts (10,26): Cannot find module './ngx-uploader.module'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/people/people.component.ngfactory.ts (1292,11): Type 'MProfile | IConversationProfile' is not assignable to
type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/conversation/conv.component.ngfactory.ts (950,11): Type 'MProfile | IConversationProfile' is not assignable
to type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.

但当我搜索任何...ngfactory.ts 时,它并不存在于文件系统.中。

所以我不知道如何调试这些错误。

EN

回答 1

Stack Overflow用户

发布于 2017-06-11 14:59:48

NgFactory文件是页面运行时的真实文件。在开发阶段,您有模板文件和.ts文件。当您使用ng build --prod编译项目时,它也会运行AOT,并将这两个文件优先合并到ngFactories中。JIT也做了类似的事情,但在运行时。

如果没有AOT,您不会得到相同的错误,因为JIT会忽略那些模板错误。

查看您的模板文件,您有类型的强制转换错误,如

代码语言:javascript
复制
Type 'MProfile' is not assignable to type 'boolean'.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44484811

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档