Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rsgowman
Copy link
Member

@rsgowman rsgowman commented Mar 6, 2020

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.)

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.)
src/auth/user-record.ts Outdated Show resolved Hide resolved
src/index.d.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@hiranya911 hiranya911 left a 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.

src/auth/user-record.ts Outdated Show resolved Hide resolved
src/index.d.ts Outdated Show resolved Hide resolved
@hiranya911 hiranya911 assigned rsgowman and unassigned hiranya911 Mar 6, 2020
Copy link
Contributor

@hiranya911 hiranya911 left a 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;
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@hiranya911 hiranya911 left a 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;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants