Skip to content

[BUG] Spreads are improperly sorted #24

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

Open
jesuscc1993 opened this issue Nov 5, 2021 · 0 comments
Open

[BUG] Spreads are improperly sorted #24

jesuscc1993 opened this issue Nov 5, 2021 · 0 comments

Comments

@jesuscc1993
Copy link

jesuscc1993 commented Nov 5, 2021

Description

Sorting an object with spreads results in fields in the wrong order, altering the result.

Given these objects:

const objA = {
  h: 1080,
  w: 1600
}

const objB = {
  ...objA,
  w: 1920
}

sorting objB with the extension results in

const objB = {
  w: 1920,
  ...objA
}

which is incorrect, as the new fields are no longer overwriting those in the spread object.

Expected result

const objB = {
  ...objA,
  w: 1920
}

objB === { h: 1080, w: 1920 }

Actual result

const objB = {
  w: 1920,
  ...objA
}

objB === { h: 1080, w: 1600 }

Environment

macOS Big Sur 11.6 (20G165)
VSC 1.62.0

@jesuscc1993 jesuscc1993 changed the title [BUG] Spreads improperly sorted [BUG] Spreads are improperly sorted Nov 5, 2021
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

No branches or pull requests

1 participant