File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -664,7 +664,7 @@ namespace ts.refactor.extractMethod {
664664 }
665665 newFunction = createMethod (
666666 /*decorators*/ undefined ,
667- modifiers ,
667+ modifiers . length ? modifiers : undefined ,
668668 range . facts & RangeFacts . IsGenerator ? createToken ( SyntaxKind . AsteriskToken ) : undefined ,
669669 functionName ,
670670 /*questionToken*/ undefined ,
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+
3+ // Handle having zero modifiers on a method.
4+
5+ // @allowNonTsExtensions : true
6+ // @Filename : file1.js
7+ //// class C {
8+ //// M() {
9+ //// const q = /*a*/1 + 2/*b*/;
10+ //// q.toString();
11+ //// }
12+ //// }
13+
14+ goTo . select ( 'a' , 'b' )
15+ edit . applyRefactor ( {
16+ refactorName : "Extract Method" ,
17+ actionName : "scope_0" ,
18+ actionDescription : "Extract to method in class 'C'" ,
19+ newContent :
20+ `class C {
21+ M() {
22+ const q = this./*RENAME*/newFunction();
23+ q.toString();
24+ }
25+
26+ newFunction() {
27+ return 1 + 2;
28+ }
29+ }`
30+ } ) ;
You can’t perform that action at this time.
0 commit comments