Skip to content

Inline local refactoring #18459

Description

@mjbvz

Proposal
Add a refactoring to inline a local variable. Example:

function generatePipeName(): string {
	const hexString = makeRandomHexString(40);
	return getPipeName(hexString);
}

The Inline local refactoring on hexString would result in:

function generatePipeName(): string {
	return getPipeName(makeRandomHexString(40));
}

Activity

  1. D0nGiovanni commented on Nov 7, 2018

    @D0nGiovanni
    Contributor

    I've been working on this issue for a while now, but I'm not too familiar with the compiler API. Is there a way to dynamically generate a new node based on the SyntaxKind of another? I'm concerned that if I just make a copy, the id will stay the same and that would lead to problems down the road.

  2. D0nGiovanni commented on Nov 8, 2018

    @D0nGiovanni
    Contributor

    Wesley Wigham (@weswigham) What is the label in discussion for? Is it being discussed whether to implement the issue at all, or is there a different meaning? I would like to implement it in the near future (1-2 weeks).

  3. weswigham commented on Nov 8, 2018

    @weswigham
    Member

    Ah, just means we're considering it for inclusion. Everything that's labeled as a "Suggestion" is supposed to have one of a set of sublabels indicative of the issue's state. I felt that was probably most correct here (it's not "committed" because we've not allocated anyone to work on it).

  4. jackric commented on Jul 7, 2020

    @jackric

    Anyone suggest a VSCode extension that does this in lieu of waiting for official support?

  5. OliverJAsh commented on Aug 28, 2020

    @OliverJAsh
    Contributor

    Anyone suggest a VSCode extension that does this in lieu of waiting for official support?

    https://github.com/nicoespeon/abracadabra#inline-variable

  6. olfek commented on Mar 19, 2023

    @olfek

    2023

  7. tylerlaprade commented on Jun 14, 2023

    @tylerlaprade

    Thanks Maria Solano (@MariaSolOs) for the fix! Will the documentation be updated to match?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: LS: Refactoringse.g. extract to constant or function, rename symbolFix AvailableA PR has been opened for this issueIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions