简体   繁体   English

Angular 9 Ivy - 通用类型 'ɵɵFactoryDef' 需要 2 个类型参数

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

Looks like Angular Ivy not ready yet.看起来 Angular Ivy 还没有准备好。 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 .我正在尝试使用 ivy 构建我的项目,这是 Angular 9 的主要思想。许多库与此功能不兼容,其中一个库是@angular/flex-layout Material and service-worker have the same problem as well. Material 和 service-worker 也有同样的问题。

After using ng build --prod --aot -c=production script to build my project I got:使用ng build --prod --aot -c=production script 构建我的项目后,我得到:

                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.错误比我上面写的要长,我花时间好好搜索这个问题,除了禁用 ivy 之外什么都没有,这不是一个好的选择。

Fortunately, Angular 9.1 has been released and the problem solved.幸运的是,Angular 9.1 已经发布并且问题解决了。 After upgrading to 9.1 (by running ng update @angular/cli @angular/core ) I deleted my node_modules and reinstall it again.升级到 9.1 后(通过运行ng update @angular/cli @angular/core )我删除了我的 node_modules 并重新安装它。 Then I upgraded my typescript from 3.7.5 to 3.8.3 .然后我将我的打字稿从3.7.5升级到3.8.3 Now the ngcc is working fine and I have no errors after building.现在 ngcc 工作正常,构建后我没有错误。

For more info: Angular Version 9.1欲了解更多信息: Angular 9.1 版

In my case was to remove node_modules folder completely and run an npm install after that it works在我的例子中是完全删除 node_modules 文件夹并运行npm 安装,然后它工作

You might get the below error by using ng update @angular/cli @angular/core使用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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 @ angular / forms通用类型&#39;类型 <T> &#39;需要1种类型的参数 - @angular/forms Generic type 'Type<T>' requires 1 type argument(s) 通用类型“Array <T>”需要1个类型的参数。 - Angular2 - Generic type 'Array<T>' requires 1 type argument(s). - Angular2 Angular 错误 - 通用类型“ModuleWithProviders”<t> ' 需要 1 个类型参数</t> - Angular error - Generic type 'ModuleWithProviders<T>' requires 1 type argument(s) 通用类型主题<t>需要 1 个类型参数。 - Angular</t> - Generic type Subject<T> requires 1 type argument(s). - Angular Angular 10 Swagger 代码生成:通用类型 ModuleWithProviders<t> 需要 1 个类型参数</t> - Angular 10 Swagger Codegen: Generic type ModuleWithProviders<T> requires 1 type argument(s) opentok angular 6 错误 TS2314:通用类型 &#39;Promise<T> &#39; 需要 1 个类型参数 - opentok angular 6 error TS2314: Generic type 'Promise<T>' requires 1 type argument(s) JWT 库错误:通用类型 'ModuleWithProviders<t> ' 在 Angular 10 中需要 1 个类型参数</t> - JWT library error: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s) in Angular 10 Angular 5升级错误:通用类型&#39;InjectionToken <T> &#39;需要1种类型的参数 - Angular 5 Upgrade Error: Generic type 'InjectionToken<T>' requires 1 type argument(s) “如何修复‘错误:(5, 12) TS2314:通用类型‘数组<T> &#39;在 Angular 中需要 1 个类型参数&#39; - "How to fix 'Error:(5, 12) TS2314: Generic type 'Array<T>' requires 1 type argument(s) ' in Angular" Angular 11 通用类型'HttpRequest<t> ' 需要 1 个类型的参数。ts(2314)</t> - Angular 11 Generic type 'HttpRequest<T>' requires 1 type argument(s).ts(2314)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM