File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -546,6 +546,13 @@ var q = /*b*/ //c
546546 /*g*/ + /*h*/ //i
547547 /*j*/ 2|] /*k*/ //l
548548 /*m*/; /*n*/ //o` ) ;
549+
550+ testExtractFunction ( "extractFunction_NamelessClass" , `
551+ export default class {
552+ M() {
553+ [#|1 + 1|];
554+ }
555+ }` ) ;
549556 } ) ;
550557
551558 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 {
687687 }
688688 function getDescriptionForClassLikeDeclaration ( scope : ClassLikeDeclaration ) : string {
689689 return scope . kind === SyntaxKind . ClassDeclaration
690- ? `class '${ scope . name . text } '`
690+ ? scope . name ? `class '${ scope . name . text } '` : "anonymous class declaration"
691691 : scope . name ? `class expression '${ scope . name . text } '` : "anonymous class expression" ;
692692 }
693693 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