简体   繁体   English

如何使用 Firebase 9.x + Flow

[英]How can I use Firebase 9.x + Flow

I'm working on a NextJS project using Flow and I'm trying to import Firebase latest version 9.1.3, but when I try to use it, Flow complains that cannot find the module.我正在使用Flow处理 NextJS 项目,并且正在尝试导入Firebase最新版本 9.1.3,但是当我尝试使用它时,Flow 抱怨找不到该模块。

// Error: Cannot resolve module `firebase/app`.Flow(cannot-resolve-module)
import { initializeApp, getApps } from 'firebase/app';
import { getAnalytics } from 'firebase/analytics';

I only found an old solution on flow-typed for Firebase 5.xx, but API has changed since then, and manually writing a Library Definition is super time consuming.我只Firebase 5.xx 的流类型上找到了一个旧的解决方案,但从那时起 API 发生了变化,手动编写库定义非常耗时。

I noticed that Firebase uses Typescript, is there a way I can import/convert to use Flow?我注意到 Firebase 使用 Typescript,有什么方法可以导入/转换以使用 Flow?

No flow types and TS types are not compatible although they achieve the same goal they are different in their typing philosophy.没有流类型和 TS 类型不兼容,尽管它们实现了相同的目标,但它们的类型哲学不同。

Regarding firebase types, because firebase doesn't use flow, flow-typed is the correct place to retrieve them if the existed but no one has done so for firebase types for a while.关于 firebase 类型,因为 firebase 不使用流,如果存在但没有人对 firebase 类型这样做过一段时间,则流类型是检索它们的正确位置。

I have personally made a start in a project I started a while back but you may need to add more to suit your usecase ( firebase types in my project ).我个人已经开始了我不久前开始的一个项目,但您可能需要添加更多内容以适合您的用例( 我的项目中的 firebase 类型)。 If these suit your usecase as a base I'm happy to commit them into flow-typed but I'll just need to include some tests.如果这些适合您的用例作为基础,我很乐意将它们提交到流类型中,但我只需要包含一些测试。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM