File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2134,7 +2134,7 @@ namespace ts {
21342134 if ( node . variableDeclaration ) {
21352135 writeToken ( SyntaxKind . OpenParenToken , openParenPos ) ;
21362136 emit ( node . variableDeclaration ) ;
2137- writeToken ( SyntaxKind . CloseParenToken , node . variableDeclaration ? node . variableDeclaration . end : openParenPos ) ;
2137+ writeToken ( SyntaxKind . CloseParenToken , node . variableDeclaration . end ) ;
21382138 write ( " " ) ;
21392139 }
21402140 emit ( node . block ) ;
Original file line number Diff line number Diff line change @@ -2128,14 +2128,14 @@ namespace ts {
21282128 : node ;
21292129 }
21302130
2131- export function createCatchClause ( variableDeclaration : string | VariableDeclaration , block : Block ) {
2131+ export function createCatchClause ( variableDeclaration : string | VariableDeclaration | undefined , block : Block ) {
21322132 const node = < CatchClause > createSynthesizedNode ( SyntaxKind . CatchClause ) ;
21332133 node . variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration ( variableDeclaration ) : variableDeclaration ;
21342134 node . block = block ;
21352135 return node ;
21362136 }
21372137
2138- export function updateCatchClause ( node : CatchClause , variableDeclaration : VariableDeclaration , block : Block ) {
2138+ export function updateCatchClause ( node : CatchClause , variableDeclaration : VariableDeclaration | undefined , block : Block ) {
21392139 return node . variableDeclaration !== variableDeclaration
21402140 || node . block !== block
21412141 ? updateNode ( createCatchClause ( variableDeclaration , block ) , node )
Original file line number Diff line number Diff line change @@ -4783,6 +4783,10 @@ namespace ts {
47834783 result . variableDeclaration = parseVariableDeclaration ( ) ;
47844784 parseExpected ( SyntaxKind . CloseParenToken ) ;
47854785 }
4786+ else {
4787+ // Keep shape of node to not avoid degrading performance.
4788+ result . variableDeclaration = undefined ;
4789+ }
47864790
47874791 result . block = parseBlock ( /*ignoreMissingOpenBrace*/ false ) ;
47884792 return finishNode ( result ) ;
Original file line number Diff line number Diff line change @@ -3173,7 +3173,7 @@ namespace ts {
31733173 function visitCatchClause ( node : CatchClause ) : CatchClause {
31743174 const ancestorFacts = enterSubtree ( HierarchyFacts . BlockScopeExcludes , HierarchyFacts . BlockScopeIncludes ) ;
31753175 let updated : CatchClause ;
3176- Debug . assert ( ! ! node . variableDeclaration , "Catch clauses should always be present when downleveling ES2015 code ." ) ;
3176+ Debug . assert ( ! ! node . variableDeclaration , "Catch clause variable should always be present when downleveling ES2015." ) ;
31773177 if ( isBindingPattern ( node . variableDeclaration . name ) ) {
31783178 const temp = createTempVariable ( /*recordTempVariable*/ undefined ) ;
31793179 const newVariableDeclaration = createVariableDeclaration ( temp ) ;
Original file line number Diff line number Diff line change @@ -1807,7 +1807,7 @@ namespace ts {
18071807
18081808 export interface CatchClause extends Node {
18091809 kind : SyntaxKind . CatchClause ;
1810- parent ?: TryStatement ; // We make this optional to parse missing try statements
1810+ parent ?: TryStatement ;
18111811 variableDeclaration ?: VariableDeclaration ;
18121812 block : Block ;
18131813 }
You can’t perform that action at this time.
0 commit comments