-
Notifications
You must be signed in to change notification settings - Fork 398
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
Type of ObservableStatus::data
should include undefined
#577
Comments
Agree. I've always found the inaccurate types confusing. It leads to error prone code, since the result of these hooks is briefly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version info
React:
Firebase:
ReactFire:
4.2.2
Other (e.g. Node, browser, operating system) (if applicable):
Test case
Steps to reproduce
Description
The Firestore access hooks, e.g.
useFirestoreDoc()
,useFirestoreCollection()
etc, all return anObservableStatus
object. TheObservableStatus
interface guarantees the presence ofdata
, which is untrue, since it will initially beundefined
(unless using suspense).Currently,
ObservableStatus
is defined as follows:Expected behavior
I expect the types to indicate that
Observable::data
is eitherT | undefined
.Actual behavior
The type system does not warn you when accessing properties on
data
while it'sundefined
.At run time it throws an error attempting to access properties on undefined.
The text was updated successfully, but these errors were encountered: