Angular 9 Ivy - Generic type 'ɵɵFactoryDef' requires 2 type argument(s)

早过忘川 提交于 2020-07-06 05:30:41

问题


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.

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.


回答1:


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.

For more info: Angular Version 9.1



来源:https://stackoverflow.com/questions/60898133/angular-9-ivy-generic-type-%c9%b5%c9%b5factorydef-requires-2-type-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!