-
Notifications
You must be signed in to change notification settings - Fork 923
Fix messaging being optional and isSupported type definitions #793
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
Conversation
edc22aa
to
56dba41
Compare
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.
messaging?: { | ||
(app?: FirebaseApp): types.FirebaseMessaging; | ||
Messaging: typeof types.FirebaseMessaging; | ||
messaging: { |
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.
Soo... @firebase/messaging is optional; you can use @firebase/database etc. but not messaging just fine.
firebase the metapackage bundles everything together, cool.
But if you just depend on @firebase/messaging, it would monkey-patch @firebase/app-types to add itself optionally? weird
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.
They are all optional (you can import them or not), but if you import them, then the namespace exists (and the type should not be "optional" anymore). I'm not sure why that ?
ever existed, I'm hoping @jshcrowthe has an idea.
import { | ||
_FirebaseNamespace, | ||
FirebaseServiceFactory | ||
} from '@firebase/app-types/private'; |
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.
It'd be really nice to have a test that works like the docs suggests a user to, i.e.
import firebase from '@firebase/app';
import '@firebase/messaging'
// Do stuff w/ `firebase` and `firebase.messaging`
rather than poking at the internals like this :/
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.
Yeah, I agree. The tests need an overhaul (not just here). I'll get to that soon™.
Fixes firebase.messaging() method being optional in TS types. Modifies isSupported so it is a namespace export and not a property on the factory function, which is not actually exported.
9e1a304
to
4196fab
Compare
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 LGTM 👍
Fixes TS thinking
firebase.messaging()
method is optional after importing 'firebase/messaging' (removes the?
). This should be done in other packages as well, unless there's a reason for the discrepancy between importing from'firebase'
and from'firebase/packageName'
that I don't know about.Modifies
messaging.isSupported()
so it is a namespace export and not a property on the factory function, which is not actually exported. Fixes types accordingly.