-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
chore: remove lodash usage #6501
Conversation
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.
Looks like you need to run lint:fix
, see output of GitHub checks.
Sure, did it and pushed. Please review it if anytime you have. |
Please run |
@lodestar/beacon-node: $ tsc
@lodestar/beacon-node: test/unit/eth1/utils/eth1Data.test.ts:109:77 - error TS2345: Argument of type 'string[]' is not assignable to parameter of type '("depositRoot" | "depositCount" | keyof Eth1Block)[]'.
@lodestar/beacon-node: Type 'string' is not assignable to type '"depositRoot" | "depositCount" | keyof Eth1Block'.
@lodestar/beacon-node: 109 const eth1DatasPartial = eth1Datas.map((eth1Data) => pick(eth1Data, Object.keys(expectedEth1Data[0])));
@lodestar/beacon-node: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@lodestar/beacon-node: Found 1 error in test/unit/eth1/utils/eth1Data.test.ts:109 |
According to the Error. Changed |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6501 +/- ##
=========================================
Coverage 61.72% 61.72%
=========================================
Files 555 555
Lines 58206 58206
Branches 1844 1844
=========================================
Hits 35929 35929
Misses 22238 22238
Partials 39 39 |
@@ -274,3 +273,15 @@ function getMockDeposit({blockNumber, index}: {blockNumber: number; index: numbe | |||
depositData: {} as phase0.DepositData, // Not used | |||
}; | |||
} | |||
|
|||
function pick<T, K extends keyof T>(obj: T, keys: string[]): Pick<T, K> { | |||
return (keys as K[]).reduce( |
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.
Do we need this cast?
Also I am skeptical we need this Pick
use here.
A different path would be to replca the pick
usage altogether and replace it with something like:
...
const eth1DatasPartial = eth1Datas.map(({blockNumber, depositCount}) => ({blockNumber, depositCount}));
...
Sorry for the back and forth!
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 see.
That's must be the answer for the simplest refactoring.
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.
Your insights have really helped me improve my code. Thank you for your review.
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
Thanks @HiroyukiNaito for the effort! |
Thanks for the dedicated support! I return the favor in the another issue. |
🎉 This PR is included in v1.17.0 🎉 |
Motivation
This is fix for the issue "Remove lodash usage #6489"
Description
Replace the lodash.pick for original pick function
Closes #6489
Steps to test or reproduce
-->