-
Notifications
You must be signed in to change notification settings - Fork 376
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
Directly initialize properties in UserMetadata #803
base: master
Are you sure you want to change the base?
Directly initialize properties in UserMetadata #803
Conversation
Prompted by attempting to enable tsconfig options 'strictPropertyInitialization'. The properties were being indirectly set via Object.defineProperty. Typescript isn't able to follow that. Setting the properties directly resolves it. (And also exposed some minor type errors.)
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.
Mostly looks ok. Just a comment on making required fields optional.
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 with a suggestion.
@@ -491,13 +491,12 @@ declare namespace admin.auth { | |||
/** | |||
* The date the user last signed in, formatted as a UTC string. | |||
*/ | |||
lastSignInTime: string; | |||
lastSignInTime: string | 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.
Nit: Let's also update the doc comment to indicate when these values are 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.
Done. Though note that there's not a great explanation as to why creationTime might be null. As an alternative, we could keep it as non-nullable and change the implementation to throw an internal error if this situation occurs.
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.
That sounds like the right approach to me.
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.
Done. A number of unit tests needed to be changed as a result. I think the changes are correct, but definitely will want Bassam to weigh in on this too.
…ertyInitialization_investigation
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 from me with a comment on the docs.
@@ -491,13 +491,12 @@ declare namespace admin.auth { | |||
/** | |||
* The date the user last signed in, formatted as a UTC string. | |||
*/ | |||
lastSignInTime: string; | |||
lastSignInTime: string | 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.
That sounds like the right approach to me.
Prompted by attempting to enable tsconfig options
'strictPropertyInitialization'.
The properties were being indirectly set via Object.defineProperty.
Typescript isn't able to follow that. Setting the properties directly
resolves it. (And also exposed some minor type errors.)