-
Notifications
You must be signed in to change notification settings - Fork 392
Cleaned up auth user types for easier debugging #1
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
I’ve now seen several reports of people getting confused by the fact that when you log `UserRecord`, you get a bunch of properties which are named `<something>Internal`. People think those are what they should use instead of just `<something>`. This change has no functional difference other than cleaning up which these properties display when doing a `console.log()`. Change-Id: I79d79fa6bf7c0184d9db947031eecca5e9af1d4b
@@ -28,26 +29,16 @@ function parseDate(time: any): Date { | |||
* @constructor | |||
*/ | |||
export class UserMetadata { | |||
private lastSignedInAtInternal: Date; | |||
private createdAtInternal: Date; | |||
public readonly createdAt: Date; |
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.
Note that readonly
here is a compilation time check only. I think it's useful to have to make sure we don't accidentally set the property in our own codebase, but it does not enforce read-only behavior for end-users. That is why I needed to explicitly use Object.defineProperty()
below to enforce the read-only behavior.
src/utils/index.ts
Outdated
* | ||
* @return {Object} The object that was passed to the function. | ||
*/ | ||
export function addGetter(obj: Object, prop: string, value: any): void { |
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.
Maybe this should be renamed to something like addReadonlyGetter or something of the like since a getter does not necessarily imply the property does not have a setter?
Also would be helpful to a test for this, where you add a readonly property on an object, try to change its value and then check the old value is still there.
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.
Change-Id: Iddcd18cfeab45921d55f05232fad6bb1691609b2
Back to you @bojeil-google! Also, in the future, please use the GitHub UI to assign the PR back to me after you are done with your review. That way, you'll get a notification when I've assigned the PR back to you once I'm done, instead of me having to send you a comment like this. |
Description
I’ve now seen several reports of people getting confused by the fact that when you log
UserRecord
, you get a bunch of properties which are named<something>Internal
. People think those are what they should use instead of just<something>
. This change has no functional difference other than cleaning up which these properties display when doing aconsole.log()
.Code sample
Previous output:
New output: