chore: Allow type-safety for subcollections#8376
chore: Allow type-safety for subcollections#8376fivecar wants to merge 1 commit intoinvertase:mainfrom
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 PRthe returned type is LMK if that all makes sense. |
|
That does make sense - seems like this should work, thanks for your replies |
38a52cd to
7af280b
Compare
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
AndroidiOSOther(macOS, web)e2etests added or updated inpackages/\*\*/e2ejesttests added or updated inpackages/\*\*/__tests__Test Plan
Installed local version in my project, and verified that Typescript accepts a subcollection type.