Typescript: Inline local refactoring

Created on 14 Sep 2017  路  5Comments  路  Source: microsoft/TypeScript

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));
}
Refactorings In Discussion Suggestion VS Code Tracked

Most helpful comment

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

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

All 5 comments

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.

@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).

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).

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielRosenwasser picture DanielRosenwasser  路  3Comments

siddjain picture siddjain  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

remojansen picture remojansen  路  3Comments

dlaberge picture dlaberge  路  3Comments