1/*@internal*/ 2namespace ts { 3 export function transformES2019(context: TransformationContext) { 4 const factory = context.factory; 5 return chainBundle(context, transformSourceFile); 6 7 function transformSourceFile(node: SourceFile) { 8 if (node.isDeclarationFile) { 9 return node; 10 } 11 12 return visitEachChild(node, visitor, context); 13 } 14 15 function visitor(node: Node): VisitResult<Node> { 16 if ((node.transformFlags & TransformFlags.ContainsES2019) === 0) { 17 return node; 18 } 19 switch (node.kind) { 20 case SyntaxKind.CatchClause: 21 return visitCatchClause(node as CatchClause); 22 default: 23 return visitEachChild(node, visitor, context); 24 } 25 } 26 27 function visitCatchClause(node: CatchClause): CatchClause { 28 if (!node.variableDeclaration) { 29 return factory.updateCatchClause( 30 node, 31 factory.createVariableDeclaration(factory.createTempVariable(/*recordTempVariable*/ undefined)), 32 visitNode(node.block, visitor, isBlock) 33 ); 34 } 35 return visitEachChild(node, visitor, context); 36 } 37 } 38} 39