Skip to content

Conversation

@a-tarasyuk
Copy link
Contributor

Fixes #58447

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label May 7, 2024
jakebailey
jakebailey previously approved these changes Jul 24, 2024
Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

This looks great; been wanting this for ages...

Hopefully nobody actually wants the rename to duplicate the name? (I think linters actually fix this too in our favor.)

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

What the baseline is showing is not the intended behavior. Here’s a real-world reproduction of the test:

Screen.Recording.2024-07-25.at.10.20.30.AM.mov

@jakebailey
Copy link
Member

Oh, eek, yeah, I forgot that we'd need to do some step after getting the new text and then determine that they're the same, not do it early (which is what this PR does).

@andrewbranch
Copy link
Member

I don’t want to derail this feature since I don’t know how much more work it would be to tack this on, but when I initially saw the issue, I thought it was talking about property assignments, not just destructuring. I run into this a lot too:

const foo = 0;
const obj = {
  bar: foo // <-- make shorthand when renaming 'bar' to 'foo' OR vice versa?
};

@DanielRosenwasser
Copy link
Member

It feels like it would be confusing to have one but not the other to be honest.

@a-tarasyuk a-tarasyuk closed this Jul 25, 2024
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS object destructuring: allow to shorten expression when assignment is renamed back to original property value

5 participants