【问题标题】:Did Firebase.js 7.x break compatibility with Typescript 2.6.x?Firebase.js 7.x 是否破坏了与 Typescript 2.6.x 的兼容性?
【发布时间】:2020-02-27 15:11:11
【问题描述】:

在 Firebase 推出 7.0.0 版本之前,我们一直在 Ionic 3.x 项目中使用 Firebase(只是数据库),没有出现任何编译错误。 Ionic 3.x 项目使用的常见 Typescript 版本是 2.6.2。

知道升级 Typescript 依赖项不是一个选项,我们可以做些什么来解决这个问题?还是 Firebase 的错误或放弃的支持(尚未传达)?

我们导入库的方式是标准的:

import * as firebase from 'firebase/app';
import 'firebase/database';

离子服务输出:

[app-scripts] [10:36:47]  transpile started ... 
[app-scripts] [10:36:54]  typescript: node_modules/firebase/index.d.ts, line: 4336 
[app-scripts]             ';' expected. 
[app-scripts]     L4335:  gtagName?: string;
[app-scripts]     L4336:  /** Sets custom name for `dataLayer` array used by gtag. */
[app-scripts]     L4337:  dataLayerName?: string;
[app-scripts] [10:36:54]  typescript: node_modules/firebase/index.d.ts, line: 4336 
[app-scripts]             'EventNameString' only refers to a type, but is being used as a value here. 
[app-scripts]     L4335:  gtagName?: string;
[app-scripts]     L4336:  /** Sets custom name for `dataLayer` array used by gtag. */
[app-scripts]     L4337:  dataLayerName?: string;
[app-scripts]             'never' only refers to a type, but is being used as a value here. 
[app-scripts]     L4335:  gtagName?: string;
[app-scripts] [10:36:54]  typescript: node_modules/firebase/index.d.ts, line: 4336 
[app-scripts] [10:36:54]  typescript: node_modules/firebase/index.d.ts, line: 4336 
[app-scripts]     L4336:  /** Sets custom name for `dataLayer` array used by gtag. */     
[app-scripts]     L4337:  dataLayerName?: string;
[app-scripts]             Cannot find name 'T'. 
[app-scripts]     L4335:  gtagName?: string;
[app-scripts]     L4336:  /** Sets custom name for `dataLayer` array used by gtag. */ 
[app-scripts]     L4337:  dataLayerName?: string;

因此,我们暂时只能使用 firebase 6.6.2。

【问题讨论】:

标签: typescript firebase ionic-framework


【解决方案1】:

简短的回答 - 是的。 Firebase 的好人提供了一些启示: https://github.com/firebase/firebase-js-sdk/issues/2335#issuecomment-549606361

是的,它确实破坏了与 2.8 之前的 Typescript 版本的兼容性。这不是故意的,但我们使用了 2.8 之前的 Typescript 版本无法识别的条件类型进行分析。你能升级你的 Typescript 版本吗?我能够在我的测试 Ionic 项目中 npm i typescript@latest 并成功运行它,但我不知道您是否有其他限制阻止您升级。

我们正在研究如何为早期 Typescript 版本的用户修复它,但如果您能够安全地将 Typescript 升级到 2.8+,这可能是目前解除阻止您的最快方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-02
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多