File tree 2 files changed +31
-1
lines changed
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -664,7 +664,7 @@ namespace ts.refactor.extractMethod {
664
664
}
665
665
newFunction = createMethod (
666
666
/*decorators*/ undefined ,
667
- modifiers ,
667
+ modifiers . length ? modifiers : undefined ,
668
668
range . facts & RangeFacts . IsGenerator ? createToken ( SyntaxKind . AsteriskToken ) : undefined ,
669
669
functionName ,
670
670
/*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