You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactoring cases for which we can improve discoverability
This is the list of our refactors TSServer offers and the proposed changes to make them more discoverable. See #34930 for the broader discussion.
Here I have listed the current behavior as well as proposed changes to make the refactors more discoverable. Some of these ideas may offer refactors too frequently/infrequently, so more input is desired. The explicit refactoring request cases mentioned depend on #35096.
This issue does not list any code fixes.
addOrRemoveBracesToArrowFunction
Case - remove braces:
consta=(n: number)=>{returnn;}
Current:
Refactor offered for cursor or selection start in range (n: number). selection end can be anywhere else.
Proposed:
Explicit request offers refactor for cursor or selection anywhere in function including body.
Implict refactor seems OK as is.
convertExport
Case - Convert default export to named export:
exportdefaultfunctionf();
Case - Convert named export to default:
exportfunctionf();
Current:
Refactor offered only when entire range is selected.
Proposed:
Explicit request offers refactor for cursor or selection anywhere in range.
Implicit refactor triggers for cursor or selection anywhere in ranges f() or default.
Note this refactor only applies when the only statement in the function is a return statement, so we aren't in danger of offering up this refactor too much. We may even be fine offering it as often as in the explicit case.
convertImport
Case - Convert namespace import to named imports:
import*asafrom"./a";
Case - Convert named import to namespace import:
import{f}from"./a";
Current:
Refactor offered only when entire range is selected.
Proposed:
Explicit request offers refactor for cursor or selection start anywhere in range. Implicit refactor triggers anywhere in * as a or { f }.
extractSymbol
Case - extract const
functionfoo(a: any){returna+20*10;}
Current:
No refactor offered for cursor anywhere within statement.
Refactor offered for selection if selection start and end are within the same Literal. For example, selecting 2 offers to extract 20. This is not the case for other valid extraction candidates such as Identifiers or functions.
No refactor offered for selections if selection start and end are in the LHS and RHS of the same binary expression, but do not span it. For example, if 20 + 1 is selected, no refactor is offered.
Refactoring cases for which we can improve discoverability
This is the list of our refactors TSServer offers and the proposed changes to make them more discoverable. See #34930 for the broader discussion.
Here I have listed the current behavior as well as proposed changes to make the refactors more discoverable. Some of these ideas may offer refactors too frequently/infrequently, so more input is desired. The explicit refactoring request cases mentioned depend on #35096.
This issue does not list any code fixes.
addOrRemoveBracesToArrowFunction
Case - remove braces:
Current:
(n: number). selection end can be anywhere else.Proposed:
convertExport
Case - Convert default export to named export:
Case - Convert named export to default:
Current:
Proposed:
f()ordefault.returnstatement, so we aren't in danger of offering up this refactor too much. We may even be fine offering it as often as in the explicit case.convertImport
Case - Convert namespace import to named imports:
Case - Convert named import to namespace import:
Current:
Proposed:
* as aor{ f }.extractSymbol
Case - extract const
Current:
2offers to extract20. This is not the case for other valid extraction candidates such as Identifiers or functions.20 + 1is selected, no refactor is offered.Proposed:
Case - extract method
Current
Proposed:
functionkeyword (or both).function bar.extractType
Case - extract to type alias
Current:
stringselected.Proposed:
stringas the selecting whole type.stringCase - extract to interface
Current:
{ a?: number, b?: string }selected.Proposed:
generateGetAccessorAndSetAccessor
Case - Generate 'get' and 'set' accessors
Current:
convertMe.Proposed:
Refactors that are probably okay
Included for completeness. These cases are probably fine as is.
convertParamsToDestructuredObject
Current:
function f(a: number, b: number. Selection end can be anywhere else.convertStringOrTemplateLiteral
Current:
a + "so below. Selection end can be anywhere else.moveToNewFile
Current: