Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakubhruby
Copy link
Contributor

Fixes #285

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};
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used anywhere

@jakubhruby
Copy link
Contributor Author

ping

@jakubhruby
Copy link
Contributor Author

@terehov ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Only a few levels are printed in pretty mode
1 participant