-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
fix object extension #293
base: master
Are you sure you want to change the base?
fix object extension #293
Conversation
function _extend(origin: object, add: object): object { | ||
const typedOrigin = { ...origin } as { [key: string]: unknown }; | ||
function _extend(origin: object, add: object): void { | ||
const typedOrigin = origin as {[key: string]: unknown}; |
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.
It has to be exactly the same object. If it is cloned, only typedOrigin
is extended, not origin
.
@@ -377,19 +377,18 @@ function reduceToSingleString(output: string[], base: string, braces: string[]): | |||
return braces[0] + (base === "" ? "" : base + "\n") + " " + output.join(",\n ") + " " + braces[1]; | |||
} | |||
|
|||
function _extend(origin: object, add: object): object { | |||
const typedOrigin = { ...origin } as { [key: string]: unknown }; | |||
function _extend(origin: object, add: object): 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.
Return value is not used anywhere, it only confuses what exactly is done here. Apparently this method is meant to only alter provided origin
and not to return anything.
|
||
const keys = Object.keys(add); | ||
let i = keys.length; | ||
while (i--) { | ||
typedOrigin[keys[i]] = clonedAdd[keys[i]]; | ||
} | ||
return typedOrigin; |
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.
not used anywhere
ping |
@terehov ? |
Fixes #285