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

3

29

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.

Zuckerman answered 28/3, 2020 at 6:49 Comment(0)
Z
28

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

Zuckerman answered 30/3, 2020 at 12:32 Comment(7)
what is your complete postinstall command? is it only "postinstall":"ngcc"??Sperling
@Sperling Yes it is "ngcc", If you are upgrading don't use entry point. Just stay with ngccZuckerman
I am still facing the issue... had to revert to 9.0.5 to resolve the issueSperling
@Sperling Did you remove your node_modules and reinstall it again? What is exactly your error?Zuckerman
yes, I did that... i updated typescript n all other packages. deleted node_modules and resinstalled everything, but still getting exactly the same error which you mentioned in your question. Do i need to clear global cache?Sperling
@Sperling Yes try to clear cache and make sure your package should be latest. My version is "@angular/flex-layout": "^9.0.0-beta.29"Zuckerman
Yes, removing node_modules and npm cache verify did the trick for meGibbsite
D
2

You might get the below error by using ng update @angular/cli @angular/core

Error: Repository is not clean. Please commit or stash any changes before updating.

Use command

ng update @angular/cli @angular/core --allow-dirty
Deherrera answered 24/6, 2022 at 11:38 Comment(0)
W
2

In my case was to remove node_modules folder completely and run an npm install after that it works

Wrecker answered 16/11, 2022 at 10:18 Comment(1)
Thanks, it worked for me. I had imported @angular/cdk/scrolling & had same issue!Perlaperle

© 2022 - 2024 — McMap. All rights reserved.