错误@angular/fire构建错误地扩展了接口

2024-01-11

我开始新的 Ionic/Angular 项目并添加 @Angular/Fire 包。
当我运行“ionicserve”时,出现以下错误:

Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:18 - error TS2430: Interface 'DocumentSnapshotExists<T>' incorrectly extends interface 'DocumentSnapshot<DocumentData>'.
The types returned by 'data(...)' are incompatible between these types.
    Type 'T' is not assignable to type 'DocumentData | undefined'.
    Type 'T' is not assignable to type 'DocumentData'.

13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {

node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:41
    13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
    This type parameter might need an `extends firebase.firestore.DocumentData` constraint.
node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:41
    13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
    This type parameter might need an `extends firebase.firestore.DocumentData | undefined` constraint.


Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:23:18 - error TS2430: Interface 'QueryDocumentSnapshot<T>' incorrectly extends interface 'QueryDocumentSnapshot<DocumentData>'.
The types returned by 'data(...)' are incompatible between these types.
    Type 'T' is not assignable to type 'DocumentData'.

23 export interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot {

node_modules/@angular/fire/compat/firestore/interfaces.d.ts:23:40
    23 export interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot {
    This type parameter might need an `extends firebase.firestore.DocumentData` constraint.


Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:26:18 - error TS2430: Interface 'QuerySnapshot<T>' incorrectly extends interface 'QuerySnapshot<DocumentData>'.
Types of property 'docs' are incompatible.
    Type 'QueryDocumentSnapshot<T>[]' is not assignable to type 'QueryDocumentSnapshot<DocumentData>[]'.
    Type 'QueryDocumentSnapshot<T>' is not assignable to type 'QueryDocumentSnapshot<DocumentData>'.
        The types returned by 'data(...)' are incompatible between these types.
        Type 'T' is not assignable to type 'DocumentData'.

26 export interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot {

node_modules/@angular/fire/compat/firestore/interfaces.d.ts:26:32
    26 export interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot {
    This type parameter might need an `extends firebase.firestore.DocumentData` constraint.


Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:29:18 - error TS2430: Interface 'DocumentChange<T>' incorrectly extends interface 'DocumentChange<DocumentData>'.
The types returned by 'doc.data(...)' are incompatible between these types.
    Type 'T' is not assignable to type 'DocumentData'.

29 export interface DocumentChange<T> extends firebase.firestore.DocumentChange {

node_modules/@angular/fire/compat/firestore/interfaces.d.ts:29:33
    29 export interface DocumentChange<T> extends firebase.firestore.DocumentChange {
    This type parameter might need an `extends firebase.firestore.DocumentData` constraint.

这是我的配置。 包.json:

"@angular/common": "^15.0.0",
"@angular/core": "^15.0.0",
"@angular/fire": "^7.5.0",
"@angular/forms": "^15.0.0",
"@angular/platform-browser": "^15.0.0",
"@angular/platform-browser-dynamic": "^15.0.0",
"@angular/router": "^15.0.0",
"@angular/service-worker": "^15.0.0",
"@capacitor/app": "4.1.1",
"@capacitor/core": "4.6.1",
"@capacitor/haptics": "4.1.0",
"@capacitor/keyboard": "4.1.0",
"@capacitor/status-bar": "4.1.1",
"@ionic/angular": "^6.1.9",
"@ionic/pwa-elements": "^3.1.1",
"ionicons": "^6.0.3",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"

包lock.json:

"node_modules/@angular/fire": {
  "version": "7.5.0",
  ...
  "dependencies": {
    "...
    "firebase": "^9.8.0",
    ...
  },

"node_modules/firebase": {
  "version": "9.15.0",
  "resolved": "https://registry.npmjs.org/firebase/-/firebase-9.15.0.tgz",
  ...
},  

应用程序模块.ts:

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    IonicModule.forRoot(),
    AppRoutingModule,
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFireAuthModule,
    AngularFireDatabaseModule,
    AngularFireStorageModule,
    AngularFirestoreModule,
    AngularFireFunctionsModule
  ],
  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
  bootstrap: [AppComponent],
})
export class AppModule { }

有什么想法可以解决吗?
我读过类似的问题,但针对的是旧版本,而不是我的。


这解决了我的问题。

添加以下内容tsconfig.json

{ 
   "compilerOptions": { "skipLibCheck": true, } 
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误@angular/fire构建错误地扩展了接口 的相关文章

随机推荐

  • 在 C++ 中将结构体转换为 int

    我有一个结构来表示 29 位 CAN 标识符 其位字段如下 struct canId u8 priority 3 u8 reserved 1 u8 dataPage 1 u8 pduFormat 8 u8 pduSpecific 8 u8
  • 如何使用 Azure DevOps 处理 React 应用程序中的多个环境

    开发人员在那里 我在尝试使用 Azure DevOps 在我的 React 项目中设置多个环境时遇到了一些问题 关于如何完成这项工作的信息并不多 我可以看到如何做到这一点 我想要 发展 生产 目前我已经在我的 React 应用程序上实现了它
  • CORS和XSS有什么联系吗?

    维基百科页面中提到了跨站脚本 XSS CORS http en wikipedia org wiki Cross origin resource sharing 但我不明白它们有什么关系 CORS 和 XSS 之间有什么联系 维基百科文章中
  • 如何从 Android 中的应用程序中删除共享首选项数据

    如何删除我的应用程序的 SharedPreferences 数据 我正在创建一个使用大量 Web 服务来同步数据的应用程序 出于测试目的 我需要在重新启动应用程序时清除一些 SharedPreferences 值 要删除特定值 Shared
  • 使用 Knockout foreach 绑定嵌套数组

    我需要帮助使用淘汰 foreach 绑定嵌套数组 下面是代码 想知道如何获取 PatAppointments 数组中的元素
  • 仅当传入值时才执行Where条件

    我有以下 LINQ 语句where on the date and a LabID 我正在传递实验室列表和日期 但是它们不是必需的 并且我可能只传递日期 而不传递实验室 在这种情况下 我想获取该特定实验室的所有实验室的结果 这是我现在所拥有
  • 删除位图的黑色背景颜色

    我需要在 C VS2013 中删除位图的黑色背景颜色 就像我在画布上画一些点一样 这canvas是黑色的 我只需要将画布更改为透明的同时保持其上的彩色点不做任何改变 我在以下位置得到了解决方案 如何从位图中删除白色背景色 https sta
  • 如何在 Windows 服务中使用 Threadpool.QueueUserWorkItem?

    我有一个 Windows 服务 正在使用 Threadpool QueueUserWorkItem 该服务连接到多个客户端数据库 抓取数据 转换为 XLS 并将文件发送到相应的 FTP 我对下面的代码有 3 个问题 我是否正确使用 Thre
  • 使用 FParsec 解析方法参数

    我正在尝试使用 FParsec 实现方法参数解析器 我想知道 FParsec 本身是否有一些已经实现的功能可以帮助我实现此目的 我问这个问题是因为 FParsec 在处理运算符优先级时提供了工具 所以可能也有一些东西可以解决这个问题 解析左
  • Zend GetText 和 .mo .po 文件

    我继承了一家开发公司的应用程序 我需要为我的网站生成 mo 和 po 文件 这是我在引导程序中的内容 translate new Zend Translate gettext ROOT PATH languages en default m
  • C# - Visual Studion 2022 中的多行逐字字符串不包含换行符 (\r)

    我们在定义逐字多行字符串时面临问题 some string 在 Visual Studio 2022 中 虽然我们在 Windows 机器和变量上编译代码Environment NewLine定义 r n作为新行 逐字多行字符串仅包含 n
  • 在 Airflow GUI 外部创建连接

    我想在不与 Airflow GUI 交互的情况下创建 S3 连接 是否可以通过airflow cfg或命令行 我们正在使用 AWS 角色 以下连接参数适用于我们 aws account id xxxx role arn yyyyy 因此 在
  • 适合初学者的 Slim 框架 [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 人们如何学习如何使用这个系统 我似乎找不到任何教程或书籍或任何有关如何使用该程序的内容 是的 他们的网站简要解释了一些事情 但没有任何澄清
  • 如何获取WebBrowser控件中的页面标题?

    当我导航到不同的网站时 如何获取 WebBrowser 控件中的页面标题 xmlns xmlns phone clr namespace Microsoft Phone Controls assembly Microsoft Phone 以
  • 为什么Android要求包名至少有两个标识符?

    创建新的 Android 应用程序时 Eclipse http androidcodingtips blogspot com 2011 08 package name must have at least two html抱怨Package
  • 解析附近时 JSON 中位置 XXX 出现意外标记的错误

    I npm install在一个目录上package json对于我的公司项目 然而 它不断给我带来各种错误 Unexpected token in JSON at position 我已经做好了npm cache clean force
  • 在 Bootstrap 3 中启用触摸事件的推荐方法?

    既然 Bootstrap 3 已经发布 那么启用触摸的推荐选项是什么 像之前一样 https stackoverflow com questions 16759299 is twitter bootstrap suitable for to
  • 音频播放完毕后通知

    嗯 我正在尝试实现录音的基本功能 例如 录音 播放 暂停 停止 我可以完成所有这些 但唯一的问题是音频完成后如何收到通知 玩 我的意思是 如果我播放一个音频文件 那么一旦它播放完毕 我想要一个它现在停止的通知 到目前为止我已经用过 mPla
  • 在 Roxygen 中记录时:如何在 @details 中制作逐项列表?

    例如 在 details 部分中向 roxygen2 添加逐项列表的适当语法是什么 我可以创建一个 Latex 列表环境吗 似乎换行符被简单地忽略了 即 details text describing parameter inputs in
  • 错误@angular/fire构建错误地扩展了接口

    我开始新的 Ionic Angular 项目并添加 Angular Fire 包 当我运行 ionicserve 时 出现以下错误 Error node modules angular fire compat firestore inter