File tree Expand file tree Collapse file tree 4 files changed +66
-1
lines changed Expand file tree Collapse file tree 4 files changed +66
-1
lines changed Original file line number Diff line number Diff line change @@ -546,6 +546,13 @@ var q = /*b*/ //c
546
546
/*g*/ + /*h*/ //i
547
547
/*j*/ 2|] /*k*/ //l
548
548
/*m*/; /*n*/ //o` ) ;
549
+
550
+ testExtractFunction ( "extractFunction_NamelessClass" , `
551
+ export default class {
552
+ M() {
553
+ [#|1 + 1|];
554
+ }
555
+ }` ) ;
549
556
} ) ;
550
557
551
558
function testExtractFunction ( caption : string , text : string , includeLib ?: boolean ) {
Original file line number Diff line number Diff line change @@ -687,7 +687,7 @@ namespace ts.refactor.extractSymbol {
687
687
}
688
688
function getDescriptionForClassLikeDeclaration ( scope : ClassLikeDeclaration ) : string {
689
689
return scope . kind === SyntaxKind . ClassDeclaration
690
- ? `class '${ scope . name . text } '`
690
+ ? scope . name ? `class '${ scope . name . text } '` : "anonymous class declaration"
691
691
: scope . name ? `class expression '${ scope . name . text } '` : "anonymous class expression" ;
692
692
}
693
693
function getDescriptionForModuleLikeDeclaration ( scope : SourceFile | ModuleBlock ) : string | SpecialScope {
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+
3
+ export default class {
4
+ M ( ) {
5
+ /*[#|*/ 1 + 1 /*|]*/ ;
6
+ }
7
+ }
8
+ // ==SCOPE::Extract to method in anonymous class declaration==
9
+
10
+ export default class {
11
+ M ( ) {
12
+ this . /*RENAME*/ newMethod ( ) ;
13
+ }
14
+
15
+ newMethod ( ) {
16
+ 1 + 1 ;
17
+ }
18
+ }
19
+ // ==SCOPE::Extract to function in module scope==
20
+
21
+ export default class {
22
+ M ( ) {
23
+ /*RENAME*/ newFunction ( ) ;
24
+ }
25
+ }
26
+
27
+ function newFunction ( ) {
28
+ 1 + 1 ;
29
+ }
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+
3
+ export default class {
4
+ M ( ) {
5
+ /*[#|*/ 1 + 1 /*|]*/ ;
6
+ }
7
+ }
8
+ // ==SCOPE::Extract to method in anonymous class declaration==
9
+
10
+ export default class {
11
+ M ( ) {
12
+ this . /*RENAME*/ newMethod ( ) ;
13
+ }
14
+
15
+ private newMethod ( ) {
16
+ 1 + 1 ;
17
+ }
18
+ }
19
+ // ==SCOPE::Extract to function in module scope==
20
+
21
+ export default class {
22
+ M ( ) {
23
+ /*RENAME*/ newFunction ( ) ;
24
+ }
25
+ }
26
+
27
+ function newFunction ( ) {
28
+ 1 + 1 ;
29
+ }
You can’t perform that action at this time.
0 commit comments