microsoft / microsoft/TypeScript

Refactoring to convert destructuring declaration to property accesses

Open
#30,996 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Domain: LS: Refactorings Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

From https://github.com/Microsoft/vscode/issues/72502

Feature request
Add a refactoring that converts a destructured local to normal propery access:

const {x, y, z} = someObject;
console.log(x + y * z);

Would be converted to:

const newLocal = someObject;
console.log(newLocal.x + newLocal.y * newLocal.z);

We would want to also trigger a rename on newLocal, similar to how the extract refactorings work

This would be the inverse refactoring of #25946

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the related VS Code issue 72502 and the inverse refactoring in issue 25946. Define the conversion from destructured locals to property accesses, including introducing a local for the source object and triggering a rename on it. Done means the refactoring handles the requested example and has coverage for its transformation and rename behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.