File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -34,13 +34,14 @@ namespace ts.codefix {
34
34
35
35
case SyntaxKind . VariableDeclaration :
36
36
precedingNode = ctorDeclaration . parent . parent ;
37
+ newClassDeclaration = createClassFromVariableDeclaration ( ctorDeclaration as VariableDeclaration ) ;
37
38
if ( ( < VariableDeclarationList > ctorDeclaration . parent ) . declarations . length === 1 ) {
39
+ copyComments ( precedingNode , newClassDeclaration , sourceFile ) ;
38
40
deleteNode ( precedingNode ) ;
39
41
}
40
42
else {
41
43
deleteNode ( ctorDeclaration , /*inList*/ true ) ;
42
44
}
43
- newClassDeclaration = createClassFromVariableDeclaration ( ctorDeclaration as VariableDeclaration ) ;
44
45
break ;
45
46
}
46
47
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ // @allowJs : true
4
+ // @Filename : /a.js
5
+ /////** Doc */
6
+ ////const C = function() { this.x = 0; }
7
+
8
+ verify . codeFix ( {
9
+ description : "Convert function to an ES2015 class" ,
10
+ newFileContent :
11
+ `/** Doc */
12
+ class C {
13
+ constructor() { this.x = 0; }
14
+ }
15
+ ` ,
16
+ } ) ;
You can’t perform that action at this time.
0 commit comments