Angular 9 Ivy - 通用类型 'ɵɵFactoryDef' 需要 2 个类型参数 [英] Angular 9 Ivy - Generic type 'ɵɵFactoryDef' requires 2 type argument(s)
问题描述
看起来 Angular Ivy 还没有准备好.我正在尝试使用 ivy 构建我的项目,这是 Angular 9 的主要思想.许多库与此功能不兼容,其中一个库是 @angular/flex-layout
.物料和服务人员也有同样的问题.
Looks like Angular Ivy not ready yet. I'm trying to build my project using ivy which is the main idea for Angular 9. Many of libraries are not compatible with this feature, one of these library is @angular/flex-layout
. Material and service-worker have the same problem as well.
在使用 ng build --prod --aot -c=production
脚本构建我的项目后,我得到了:
After using ng build --prod --aot -c=production
script to build my project I got:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@angular/flex-layout/core/typings/media-trigger/media-trigger.d.ts:71:18 - error TS2314: Generic type 'ɵɵFactoryDef' requires 2 type argument(s).
71 static ɵfac: ɵngcc0.ɵɵFactoryDef<MediaTrigger>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@angular/flex-layout/extended/typings/show-hide/show-hide.d.ts:18:18 - error TS2314: Generic type 'ɵɵFactoryDef' requires 2 type argument(s).
18 static ɵfac: ɵngcc0.ɵɵFactoryDef<ShowHideStyleBuilder>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@angular/flex-layout/extended/typings/show-hide/show-hide.d.ts:49:18 - error TS2314: Generic type 'ɵɵFactoryDef' requires 2 type argument(s).
49 static ɵfac: ɵngcc0.ɵɵFactoryDef<ShowHideDirective>;
错误比我上面写的要长,我花时间仔细搜索了这个问题,除了禁用常春藤,这不是一个好的选择.
The error longer than what I wrote above, I took my time to have a good search for this issue, nothing on the table but disabling ivy which is not a good option.
推荐答案
幸运的是,Angular 9.1 已经发布并且问题解决了.升级到 9.1(通过运行 ng update @angular/cli @angular/core
)后,我删除了 node_modules 并重新安装.然后我将我的打字稿从 3.7.5
升级到 3.8.3
.现在 ngcc 工作正常,构建后我没有错误.
Fortunately, Angular 9.1 has been released and the problem solved. After upgrading to 9.1 (by running ng update @angular/cli @angular/core
) I deleted my node_modules and reinstall it again. Then I upgraded my typescript from 3.7.5
to 3.8.3
. Now the ngcc is working fine and I have no errors after building.
更多信息:Angular 9.1 版
这篇关于Angular 9 Ivy - 通用类型 'ɵɵFactoryDef' 需要 2 个类型参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!