Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Strong RTDB path and value types #7531

Open
mocanew opened this issue Aug 6, 2023 · 0 comments
Open

FR: Strong RTDB path and value types #7531

mocanew opened this issue Aug 6, 2023 · 0 comments

Comments

@mocanew
Copy link

mocanew commented Aug 6, 2023

Operating System

not relevant

Browser Version

not relevant

Firebase SDK Version

10.1.0

Firebase SDK Product:

Database

Describe your project's tooling

_

Describe the problem

While working extensively with Firebase RTDB with my team, we noticed a lot of bugs that needed to be caught by automated or manual testing while only being typos, more or less. This led to slow save-test-troubleshoot iterations and wasted dev time. We created a TypeScript-based solution to provide IntelliSense and statically check RTDB paths and values to speed up development while reducing these issues.

While the community has already created packages (e.g. FireSage) to fix the lack of strong typings, I strongly consider that having this as an opt-in, fully backwards compatible feature in the official SDK is crucial as it would encourage more people to use it and thus improve their DX.

I have created a basic, proof-of-concept implementation for a couple of types in @ag-media/firebase-js-sdk. Here's a demo of how this would work. Only types have been changed in @ag-media/firebase-database vs. firebase/database.

We have already implemented an almost fully-featured solution in our private packages. Instead of publishing these packages, we would like to add this functionality directly into the Firebase JS SDK, as this is the most impactful way to share it with the Firebase community. Our solution includes automatically generating the DBType typescript interface based on the RTDB bolt rules. This is a game-changer since this means there is only one source of truth, the security rules of the project's database and no wasted dev-time copying over the rtdb structure to a typescript interface.
While our solution deals with RTDB exclusively, it should be easy to adapt the types to work for Firestore.

We would like to have some acknowledgement from Firebase maintainers/contributors before starting working on the PRs since it's not an insignificant amount of work. Note that for our types to work, TypeScript 5 is required as we use const modifier on type parameters.

Steps and code to reproduce issue

_

@mocanew mocanew added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Aug 6, 2023
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants