-
Notifications
You must be signed in to change notification settings - Fork 944
Fix the type annotations in the RTDB Query.on/off/once API. #1204
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
dffba65
to
caa91c8
Compare
packages/database-types/index.d.ts
Outdated
callback?: (a: DataSnapshot, b?: string | null) => any, | ||
context?: Object | null | ||
): any; | ||
callback?: (a: DataSnapshot, b?: string) => any, |
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.
b
(aka prevChildName
) will be null in the case of child_added events where there's no predecessor.
packages/database-types/index.d.ts
Outdated
cancelCallbackOrContext?: Object | null, | ||
context?: Object | null | ||
): (a: DataSnapshot | null, b?: string) => any; | ||
callback: (a: DataSnapshot, b?: string) => any, |
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.
b
(aka prevChildName
) will be null in the case of child_added events where there's no predecessor.
@@ -65,7 +65,7 @@ export class DataEvent implements Event { | |||
| ' child_removed', | |||
public eventRegistration: EventRegistration, | |||
public snapshot: DataSnapshot, | |||
public prevName?: string | null | |||
public prevName?: string |
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.
can be null
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.
Hm, you are obviously right here and I fixed the typing to allow for this value to be null
, but I am a little confused why
change.prevName = eventCache.getPredecessorChildName( |
strictNullChecks
.
1e05d59
to
6ed946c
Compare
6ed946c
to
4b9d19a
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.
I "overhauled" this PR. There are a bunch of inconsistencies in our typings, which make touching the API types a bit confusing. We should probably invest a little bit of time and enable strictNullChecks
.
@@ -65,7 +65,7 @@ export class DataEvent implements Event { | |||
| ' child_removed', | |||
public eventRegistration: EventRegistration, | |||
public snapshot: DataSnapshot, | |||
public prevName?: string | null | |||
public prevName?: string |
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.
Hm, you are obviously right here and I fixed the typing to allow for this value to be null
, but I am a little confused why
change.prevName = eventCache.getPredecessorChildName( |
strictNullChecks
.
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
FYI- Still LGTM after changelog addition. |
This will be merged into the Firebase I/O release as it contains minor breaking changes. |
@Feiyang1 Can you merge this with the version bump? |
This fixes the nullability annotations in the RTDB Query.on/off API. The callback can be optional, but not the DataSnapshot. This is a breaking typing cleanup (as some types used to take "null"), but this updates the TS types to match the JS reference docs.
Fixes: #1188