-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
chore: Allow type-safety for subcollections #8376
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 15 days until this gets closed automatically |
@mikehardy @MichaelVerdon Would you mind taking a look, or passing to the right folks? (Apologies, wasn't sure who's best to look, but both of you seem quite active in this project) |
Hey @fivecar - sorry for the delay - thanks for posting this. A couple questions 1- what's the backwards-compatibility status for this, how it will it affect use of DocumentReference in existing code? Will everyone get type errors now if they are not specifying the second type? If so, is it possible to make that second type optional? Thanks! |
@mikehardy Thanks for the thoughtful response! What about existing code?I believe existing What about the modular APIs?I've tested with and without the modular API, and the results are the same with this PR. Using the following code as an example: return getFirestore()
.collection(Collections.SECURE_PROFILE)
.doc(uid)
.collection<PersonYouMayKnow>(Collections.PYMK); the returned type is return getFirestore()
.collection(Collections.SECURE_PROFILE)
.doc(uid)
.collection(Collections.PYMK); // OG style, the only style allowable before this PR the returned type is LMK if that all makes sense. |
That does make sense - seems like this should work, thanks for your replies |
Description
Root collections currently allow strong typing:
But subcollections cannot be typed:
This PR attempts to make that possible.
Release Summary
Support strong typing for subcollections
Checklist
Android
iOS
Other
(macOS, web)e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
Installed local version in my project, and verified that Typescript accepts a subcollection type.