-
Notifications
You must be signed in to change notification settings - Fork 147
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
fix: Add overloads for doc() and doc(id:string) #662
Conversation
@@ -2055,6 +2055,8 @@ export class CollectionReference extends Query { | |||
}); | |||
} | |||
|
|||
doc(): DocumentReference; | |||
doc(documentPath: string): DocumentReference; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This weird arrangement here is so that our JSDoc generation still works. The TypeScript compiler still validates that we do not pass "undefined" (hence the test change).
d82aaca
to
da56b06
Compare
Codecov Report
@@ Coverage Diff @@
## master #662 +/- ##
==========================================
- Coverage 61.55% 61.46% -0.09%
==========================================
Files 21 21
Lines 3418 3418
Branches 459 459
==========================================
- Hits 2104 2101 -3
- Misses 1252 1254 +2
- Partials 62 63 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #662 +/- ##
=======================================
Coverage 61.54% 61.54%
=======================================
Files 21 21
Lines 3425 3425
Branches 460 460
=======================================
Hits 2108 2108
Misses 1254 1254
Partials 63 63
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
This addresses the same issue as #658, but instead of relaxing our
CollectionReference.doc()
API, it fixes the types to reflect the invariant that we enforce via our argument validation. As in older releases, we still prevent users from passing "undefined", but with this PR this should generate a compile time error.This is based on the following little experiment:
Note that I am marking this as a "fix" rather than as a "breaking change" as any user that tried to use "undefined" before would have been broken already (and gotten a validation error). This PR will therefore go out with the next release, which is a minor version bump.