microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.94k stars 12.47k forks source link

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

Open undeletable opened 6 months ago

undeletable commented 6 months ago

Current behavior In a restructuring assignment expression, when alias is renamed back to original property's name, it has the full form (const { property: property } = testObject; in the following example): vscode-destructuring

Proposed behavior Shorten form of assignment (const { property } = testObject; in this example) - either automatically, or enabled with configuration.

psnet commented 6 months ago

Yes, confirm this feature is must have

andrewbranch commented 2 weeks ago

This is not possible with TS Server’s current rename API, but it would be possible in LSP by implementing both textDocument/prepareRename and textDocument/rename.