-
Notifications
You must be signed in to change notification settings - Fork 944
Refactor and remove object utility functions #1811
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
fbdf492
to
83b368f
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.
Thank you very much for taking it up! The more types the better! We will fix more places once we enable the global tslint checks.
I think we should also update @firebase/polyfills to include object.values
and object.entries
.
- It serves as a documentation for us
- I'd like to be able to point developers to this package and say these are the es2015+ features we use. They can manually include @firebase/polyfills if they don't want to or couldn't use Babel. We won't recommend it since we won't know what developers use in their own code, but I think it can be a nice option for people who is upgrading from v5 to v6.
@Feiyang1 No problem! Also LMK if you need any help with the TSLint stuff. Added those two to polyfills. I think that the polyfills package is going to be difficult to keep in sync unless we change It's fine like this for now though. Just an idea. |
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 love cleanup PRs! Thanks for doing this. I wonder if we can reduce our usage of the utility functions more and left some comments. Let me know what you think!
@@ -41,44 +34,50 @@ export class ChildChangeAccumulator { | |||
childKey !== '.priority', | |||
'Only non-priority child changes can be tracked.' | |||
); | |||
const oldChange = safeGet(this.changeMap_, childKey) as Change; | |||
const oldChange = this.changeMap.get(childKey); |
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.
@mikelehen Do you know if there is a reason for safeGet()
?. Are we guarding against queries for length
or something similar?
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 think it's just guarding against accidentally getting a value from the prototype chain.
f5d190a
to
407a59a
Compare
407a59a
to
eed06e8
Compare
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the ℹ️ Googlers: Go here for more info. |
eed06e8
to
407a59a
Compare
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
@mmermerkaya What is the state of the PR? any blocker? |
69c6876
to
0c4594a
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 like the simplification a lot, but I do think that we should be careful about using the Object.keys/Object.values functions as they create copies of data. There are some parts of this PR where I would really advocate we don't do that (ImmutableTree for example), but in general I think it will be better if we directly iterate everywhere without using these helpers.
I flagged some usages here, some of them may be insignificant. I also left some out where I think we don't need to bother (like the StatsCollector).
17f9aa3
to
1ab4ad0
Compare
Reverted (almost) all changes that added FWIW, the need to iterate over plain JS objects looks like a code smell to me. I'd recommend using ES6 |
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. I do want to ask @Feiyang1 about the Polyfills though, so please hold off on merging.
d2ec322
to
082b90d
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.
Just 1 question and a pending PR #1922
* cherry pick es2015+ libs * remove lib flag from installations
Used some newer JavaScript methods instead of custom implementations. Fixed types.
Also did the same things in packages that used the refactored object utility functions.