@@ -86,31 +86,34 @@ namespace ts {
8686 }
8787
8888 function asyncBodyVisitor ( node : Node ) : VisitResult < Node > {
89- switch ( node . kind ) {
90- case SyntaxKind . VariableStatement :
91- return visitVariableStatementInAsyncBody ( < VariableStatement > node ) ;
92- case SyntaxKind . ForStatement :
93- return visitForStatementInAsyncBody ( < ForStatement > node ) ;
94- case SyntaxKind . ForInStatement :
95- return visitForInStatementInAsyncBody ( < ForInStatement > node ) ;
96- case SyntaxKind . ForOfStatement :
97- return visitForOfStatementInAsyncBody ( < ForOfStatement > node ) ;
98- case SyntaxKind . CatchClause :
99- return visitCatchClauseInAsyncBody ( < CatchClause > node ) ;
100- case SyntaxKind . Block :
101- case SyntaxKind . SwitchStatement :
102- case SyntaxKind . CaseBlock :
103- case SyntaxKind . CaseClause :
104- case SyntaxKind . DefaultClause :
105- case SyntaxKind . TryStatement :
106- case SyntaxKind . DoStatement :
107- case SyntaxKind . WhileStatement :
108- case SyntaxKind . IfStatement :
109- case SyntaxKind . WithStatement :
110- case SyntaxKind . LabeledStatement :
111- return visitEachChild ( node , asyncBodyVisitor , context ) ;
89+ if ( isNodeWithPossibleHoistedDeclaration ( node ) ) {
90+ switch ( node . kind ) {
91+ case SyntaxKind . VariableStatement :
92+ return visitVariableStatementInAsyncBody ( node ) ;
93+ case SyntaxKind . ForStatement :
94+ return visitForStatementInAsyncBody ( node ) ;
95+ case SyntaxKind . ForInStatement :
96+ return visitForInStatementInAsyncBody ( node ) ;
97+ case SyntaxKind . ForOfStatement :
98+ return visitForOfStatementInAsyncBody ( node ) ;
99+ case SyntaxKind . CatchClause :
100+ return visitCatchClauseInAsyncBody ( node ) ;
101+ case SyntaxKind . Block :
102+ case SyntaxKind . SwitchStatement :
103+ case SyntaxKind . CaseBlock :
104+ case SyntaxKind . CaseClause :
105+ case SyntaxKind . DefaultClause :
106+ case SyntaxKind . TryStatement :
107+ case SyntaxKind . DoStatement :
108+ case SyntaxKind . WhileStatement :
109+ case SyntaxKind . IfStatement :
110+ case SyntaxKind . WithStatement :
111+ case SyntaxKind . LabeledStatement :
112+ return visitEachChild ( node , asyncBodyVisitor , context ) ;
113+ default :
114+ return Debug . assertNever ( node , "Unhandled node." ) ;
115+ }
112116 }
113- Debug . assert ( ! isNodeWithPossibleVarDeclaration ( node ) , "Unhandled node." ) ;
114117 return visitor ( node ) ;
115118 }
116119
0 commit comments