@@ -77,6 +77,8 @@ namespace ts {
7777 return visitObjectLiteralExpression ( node as ObjectLiteralExpression ) ;
7878 case SyntaxKind . BinaryExpression :
7979 return visitBinaryExpression ( node as BinaryExpression , noDestructuringValue ) ;
80+ case SyntaxKind . CatchClause :
81+ return visitCatchClause ( node as CatchClause ) ;
8082 case SyntaxKind . VariableDeclaration :
8183 return visitVariableDeclaration ( node as VariableDeclaration ) ;
8284 case SyntaxKind . ForOfStatement :
@@ -272,6 +274,28 @@ namespace ts {
272274 return visitEachChild ( node , visitor , context ) ;
273275 }
274276
277+ function visitCatchClause ( node : CatchClause ) {
278+ if ( node . variableDeclaration &&
279+ isBindingPattern ( node . variableDeclaration . name ) &&
280+ node . variableDeclaration . name . transformFlags & TransformFlags . ContainsObjectRestOrSpread ) {
281+ const name = getGeneratedNameForNode ( node . variableDeclaration . name ) ;
282+ const updatedDecl = updateVariableDeclaration ( node . variableDeclaration , node . variableDeclaration . name , /*type*/ undefined , name ) ;
283+ const visitedBindings = flattenDestructuringBinding ( updatedDecl , visitor , context , FlattenLevel . ObjectRest ) ;
284+ let block = visitNode ( node . block , visitor , isBlock ) ;
285+ if ( some ( visitedBindings ) ) {
286+ block = updateBlock ( block , [
287+ createVariableStatement ( /*modifiers*/ undefined , visitedBindings ) ,
288+ ...block . statements ,
289+ ] ) ;
290+ }
291+ return updateCatchClause (
292+ node ,
293+ updateVariableDeclaration ( node . variableDeclaration , name , /*type*/ undefined , /*initializer*/ undefined ) ,
294+ block ) ;
295+ }
296+ return visitEachChild ( node , visitor , context ) ;
297+ }
298+
275299 /**
276300 * Visits a VariableDeclaration node with a binding pattern.
277301 *
0 commit comments