firebase / firebase/firebase-js-sdk

FR: Better support for types in where clauses

Open
#8,116 2 comments 0 reactions 2 assignees Claimed by @MarkDuckworth View on GitHub
api: firestore needs-attention type: feature request
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### Operating System

MacOS Monterey 12.5.1

### Browser Version

123.0.6312.87

### Firebase SDK Version

^10.8.0

### Firebase SDK Product:

Firestore

### Describe your project's tooling

React app build with Vite

### Describe the problem

Hi,

I'm using Firestore with converters to get typescript support. It works pretty well, but I've noticed that it could become even more powerful in the DX department and even help fix a source of runtime errors.

I think it would be awesome if we could have checked keys when doing `where` clauses in a `query`. I have multiple times in app-development accidentally used a wrong key and gotten frustrated with not understanding various resulting errors.

I've created a little sandbox that actually implements this check. To do this, I've resorted to hacking the exported types. I also do not support the full scope of features, such as passing in `FieldValue`s and supporting other query types.

https://codesandbox.io/p/sandbox/firestore-where-types-rl9gx8?file=%2Findex.ts

I also tried to create a fork that would create these types upstream. Since the public api is created based on some automagic inference of the written code, I did not really have much luck. Hopefully somebody internal with a better grip on the build system and type situation can remedy this?

### Steps and code to reproduce issue

Open up the codesandbox to see an example of where, and how, I think the types could be improved

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.