@@ -405,24 +405,24 @@ namespace ts.refactor.extractSymbol {
405405 rangeFacts |= RangeFacts . UsesThis ;
406406 }
407407 break ;
408+ case SyntaxKind . ClassDeclaration :
409+ case SyntaxKind . FunctionDeclaration :
410+ if ( isSourceFile ( node . parent ) && node . parent . externalModuleIndicator === undefined ) {
411+ // You cannot extract global declarations
412+ ( errors || ( errors = [ ] as Diagnostic [ ] ) ) . push ( createDiagnosticForNode ( node , Messages . functionWillNotBeVisibleInTheNewScope ) ) ;
413+ }
414+ // falls through
415+ case SyntaxKind . ClassExpression :
416+ case SyntaxKind . FunctionExpression :
417+ case SyntaxKind . MethodDeclaration :
418+ case SyntaxKind . Constructor :
419+ case SyntaxKind . GetAccessor :
420+ case SyntaxKind . SetAccessor :
421+ // do not dive into functions (except arrow functions) or classes
422+ return false ;
408423 }
409424
410- if ( isFunctionLikeDeclaration ( node ) || isClassLike ( node ) ) {
411- switch ( node . kind ) {
412- case SyntaxKind . FunctionDeclaration :
413- case SyntaxKind . ClassDeclaration :
414- if ( isSourceFile ( node . parent ) && node . parent . externalModuleIndicator === undefined ) {
415- // You cannot extract global declarations
416- ( errors || ( errors = [ ] as Diagnostic [ ] ) ) . push ( createDiagnosticForNode ( node , Messages . functionWillNotBeVisibleInTheNewScope ) ) ;
417- }
418- break ;
419- }
420-
421- // do not dive into functions or classes
422- return false ;
423- }
424425 const savedPermittedJumps = permittedJumps ;
425-
426426 switch ( node . kind ) {
427427 case SyntaxKind . IfStatement :
428428 permittedJumps = PermittedJumps . None ;
0 commit comments