Cleaned up auth user types for easier debugging - #1
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
| export class UserMetadata { | ||
| private lastSignedInAtInternal: Date; | ||
| private createdAtInternal: Date; | ||
| public readonly createdAt: Date; |
There was a problem hiding this comment.
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.
| * | ||
| * @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.
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.
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: