【问题标题】:Angular Fire Module Init Error raise on Proxy代理上的 Angular Fire 模块初始化错误
【发布时间】:2021-12-30 14:11:21
【问题描述】:

我很好奇,我正在迁移到新的 Angular Fire v7.2 模块,我关注 https://github.com/angular/angularfire/blob/master/docs/install-and-setup.md#4-setup-ngmodule-for-the-angularfiremodule

但问题是当我开始使用 ng serve 为应用程序提供服务时,ng cli 引发错误:

√ Browser application bundle generation complete.

Initial Chunk Files | Names   | Raw Size
vendor.js           | vendor  |  4.03 MB |
main.js             | main    | 14.82 kB |
runtime.js          | runtime | 13.34 kB |

3 unchanged chunks

Build at: 2021-12-30T14:01:05.723Z - Hash: b84f3308c30498f1 - Time: 2321ms

Error: node_modules/@angular/fire/compat/proxy.d.ts:7:49 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
    Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
      Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
        Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
          Type 'T[string]' is not assignable to type '(...args: any) => any'.

7     [K in FunctionPropertyNames<T>]: ReturnType<T[K]> extends Promise<any> ? K : never;
                                                  ~~~~


Error: node_modules/@angular/fire/compat/proxy.d.ts:10:49 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
    Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
      Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
        Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
          Type 'T[string]' is not assignable to type '(...args: any) => any'.

10     [K in FunctionPropertyNames<T>]: ReturnType<T[K]> extends Promise<any> ? never : K;
                                                   ~~~~


Error: node_modules/@angular/fire/compat/proxy.d.ts:18:78 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[NonPromiseReturningFunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
    Type 'T[ReturnType<T[FunctionPropertyNames<T>]> extends Promise<any> ? never : FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
      Type 'T[FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
        Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
          Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
            Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
              Type 'T[string]' is not assignable to type '(...args: any) => any'.

18     [K in NonPromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>;
                                                                                ~~~~


Error: node_modules/@angular/fire/compat/proxy.d.ts:18:107 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[NonPromiseReturningFunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
    Type 'T[ReturnType<T[FunctionPropertyNames<T>]> extends Promise<any> ? never : FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
      Type 'T[FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
        Type 'T[T[keyof T] extends Function ? keyof T : never]' is not assignable to type '(...args: any) => any'.
          Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
            Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
              Type 'T[string]' is not assignable to type '(...args: any) => any'.

18     [K in NonPromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>;
                                                                                                             ~~~~


Error: node_modules/@angular/fire/compat/proxy.d.ts:20:75 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[PromiseReturningFunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
    Type 'T[ReturnType<T[FunctionPropertyNames<T>]> extends Promise<any> ? FunctionPropertyNames<T> : never]' is not assignable to type '(...args: any) => any'.
      Type 'T[FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.

20     [K in PromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => ReturnType<T[K]>;
                                                                             ~~~~


Error: node_modules/@angular/fire/compat/proxy.d.ts:20:96 - error TS2344: Type 'T[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'T[PromiseReturningFunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
    Type 'T[ReturnType<T[FunctionPropertyNames<T>]> extends Promise<any> ? FunctionPropertyNames<T> : never]' is not assignable to type '(...args: any) => any'.
      Type 'T[FunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.

20     [K in PromiseReturningFunctionPropertyNames<T>]: (...args: Parameters<T[K]>) => ReturnType<T[K]>;
                                                                                                  ~~~~




× Failed to compile.

我尝试升级有角度的、干净的 node_modules 等,但无济于事。 这是我的角度信息

PS D:\htdocs\Angular-Blog> ng --version
Your global Angular CLI version (13.1.2) is greater than your local version (13.1.1). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 13.1.1
Node: 16.13.1
Package Manager: npm 8.1.2
OS: win32 x64

Angular: 13.1.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1301.1
@angular-devkit/build-angular   13.1.1
@angular-devkit/core            13.1.1
@angular-devkit/schematics      13.1.1
@angular/cli                    13.1.1
@angular/fire                   7.2.0
@schematics/angular             13.1.1
rxjs                            7.4.0
typescript                      4.5.4

【问题讨论】:

    标签: javascript angular typescript


    【解决方案1】:

    您需要在编译器选项的 tsconfig.json 文件中设置以下值。

    "skipLibCheck": true 
    

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2018-02-13
    • 2023-03-12
    • 2021-04-20
    • 2017-06-18
    • 1970-01-01
    • 2022-08-23
    • 1970-01-01
    • 2016-10-21
    • 2021-10-28
    相关资源
    最近更新 更多