Closed msutkowski closed 4 years ago
Merging #957 into master will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #957 +/- ##
=======================================
Coverage 88.33% 88.33%
=======================================
Files 29 29
Lines 797 797
=======================================
Hits 704 704
Misses 93 93
This is awesome, nice work! Do you foresee this causing any issues for folks? It doesn't appear so
Asking so we can figure out the version for release
@prescottprue It should not as it just 'fixes' those few TS issues. The only potential issue I can think of is in regard to not using intersections which doesn't apply here - if there was a property collision, that'd throw a type error if they differed. But as it sits, there are no overlaps here that would cause that kind of issue I can see (and we'd also see that in the build).
We could look at introducing some type tests, but being that all this is doing is setting up basic interfaces pointing to the provided Google types, I don't know if that's worth it. If you want to go down that path, I'm open to it and can get a 2nd/3rd opinion as well :)
@prescottprue Side note: I just quickly scrubbed the APIs for Firebase and compared it what's currently returned by ExtendedFirebaseInstance
. There are a few more missing elements that I can tack on to ExtendedFirebaseInstance
quickly:
messaging(): firebase.messaging.Messaging;
functions(region?: string): firebase.functions.Functions;
performance(): firebase.performance.Performance;
analytics(): firebase.analytics.Analytics;
remoteConfig(): firebase.remoteConfig.RemoteConfig;
If you'd like to chat about any of this, I'm on the Reactiflux discord under the same user name (often found in #redux). I'm happy to contribute more if you're looking for additional help. Thanks!
@prescottprue Just updated to handle those scenarios. If you include plugins, they'll automatically be inferred on the instance. Example:
import firebase from "firebase/app";
import "firebase/auth";
import "firebase/database";
import "firebase/firestore";
import "@firebase/messaging";
import "@firebase/performance";
import "@firebase/functions";
import "@firebase/analytics";
// import "@firebase/remote-config";
In some component:
const firebase = useFirebase();
console.log('$', firebase.analytics(), firebase.messaging(), '...'); // firebase will have firebase.analytics(), firebase.messaging(), etc..
firebase.remoteConfig() // will throw a type error as it's not imported
Thanks to @themindoverall & @phryneas for the help!
@prescottprue I think this is good to go. Let me know if there's anything else you'd like done here.
Description
FirebaseDatabaseService
types so that you can achieve:Previously, you would've gotten 'serverTimestamp() is a static member of FieldValue'
useFirestore()
types - previouslywithFirestore
would've been close, butuseFirestore
was missing statics.We've also added inference for plugins, such as performance, analytics, remoteConfig, etc. When a user
import
s those plugins, TS will automatically allow a user to access those properties. This basically works by saying, 'if we see this known key on thefirebase
instance, use the types that we know firebase merged into the namespace'Check List
If not relevant to pull request, check off as complete
Relevant Issues