【问题标题】:error TS2300: Duplicate identifier 'type' in Angular. while running ng build错误 TS2300:Angular 中的重复标识符 \'type\'。在运行 ng build 时
【发布时间】:2022-11-22 16:02:53
【问题描述】:

错误:node_modules/@firebase/auth-compat/dist/auth-compat/index.d.ts:53:10 - 错误 TS2300:标识符“类型”重复。

尝试构建角度代码, 我在下面命令错误.

 import { type User, type Unsubscribe, type ActionCodeInfo, type UserCredential, type Auth, type IdTokenResult, type MultiFactorError, type MultiFactorResolver, type PopupRedirectResolver, type Dependencies, type AuthCredential, type ApplicationVerifier, type ConfirmationResult, type AuthProvider, type MultiFactorUser, type NextOrObserver, type ErrorFn, type CompleteFn, type ActionCodeSettings, type Persistence, type PhoneAuthCredential } from "@firebase/auth";
            ~~~~


Error: node_modules/@firebase/auth-compat/dist/auth-compat/index.d.ts:53:10 - error TS2300: Duplicate identifier 'type'.

有时我会出错所有 Firebase 兼容像这样的文件数据库兼容、存储兼容等.

这是我的包.json文件

"dependencies": {
    "@angular/animations": "^11.2.9",
    "@angular/cdk": "^13.0.2",
    "@angular/common": "~12.2.0",
    "@angular/compiler": "~12.2.0",
    "@angular/core": "~12.2.0",
    "@angular/fire": "^7.2.0",
    "@angular/forms": "~12.2.0",
    "@angular/material": "^11.2.12",
    "@angular/platform-browser": "~12.2.0",
    "@angular/platform-browser-dynamic": "~12.2.0",
    "@angular/router": "~12.2.0",
    "@ng-bootstrap/ng-bootstrap": "^10.0.0",
    "angularfire2": "^5.4.2",
    "aws-sdk": "^2.1081.0",
    "bootstrap": "^5.1.3",
    "concurrently": "^6.2.1",
    "cors": "^2.8.5",
    "file-saver": "^2.0.5",
    "firebase": "^9.4.1",
    "http": "0.0.1-security",
    "http-client": "^4.3.1",
    "http-server": "^13.0.2",
    "karma-chai": "^0.1.0",
    "karma-mocha": "^2.0.1",
    "karma-spec-reporter": "0.0.32",
    "karma-viewport": "^1.0.8",
    "mocha": "^9.1.1",
    "ngx-toastr": "^14.1.4",
    "rxjs": "~6.6.0",
    "tslib": "^2.3.0",
    "util": "^0.12.4",
    "uuid-generator-ts": "^1.1.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.2.6",
    "@angular/cli": "~12.2.6",
    "@angular/compiler-cli": "~12.2.0",
    "@types/file-saver": "^2.0.5",
    "@types/jasmine": "~3.8.0",
    "@types/node": "^12.20.46",
    "@types/uuid": "^8.3.4",
    "jasmine-core": "~3.8.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.3.5"
  }

这是我的tsconfig.json文件文件

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2017",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": false
  }
}

我试着减少9.0.0 和 ^7.0.0 中的 firebase 和 @angular/fire 版本基于角度版本.但这是行不通的。

参考这个链接更改版本。 https://www.npmjs.com/package/@angular/fire

帮助解决这个问题。

我尝试以多种方式解决该问题,但我无法解决这个问题。

我期待尽快解决问题。

【问题讨论】:

    标签: angular typescript firebase node-modules angularfire2


    【解决方案1】:

    您的导入语句中不需要单词 type。试试这个:

    import {
        User,
        Unsubscribe,
        ActionCodeInfo,
        UserCredential,
        Auth,
        IdTokenResult,
        MultiFactorError,
        MultiFactorResolver,
        PopupRedirectResolver,
        Dependencies,
        AuthCredential,
        ApplicationVerifier,
        ConfirmationResult,
        AuthProvider,
        MultiFactorUser,
        NextOrObserver,
        ErrorFn,
        CompleteFn,
        ActionCodeSettings,
        Persistence,
        PhoneAuthCredential
    } from "@firebase/auth";
    

    【讨论】:

      猜你喜欢
      • 2018-11-09
      • 2016-12-27
      • 1970-01-01
      • 2016-06-13
      • 2016-05-23
      • 2018-11-21
      • 2017-04-13
      • 2016-10-29
      • 2019-11-02
      相关资源
      最近更新 更多