mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
Addresses CR comment
This commit is contained in:
@@ -2134,7 +2134,7 @@ namespace ts {
|
||||
if (node.variableDeclaration) {
|
||||
writeToken(SyntaxKind.OpenParenToken, openParenPos);
|
||||
emit(node.variableDeclaration);
|
||||
writeToken(SyntaxKind.CloseParenToken, node.variableDeclaration ? node.variableDeclaration.end : openParenPos);
|
||||
writeToken(SyntaxKind.CloseParenToken, node.variableDeclaration.end);
|
||||
write(" ");
|
||||
}
|
||||
emit(node.block);
|
||||
|
||||
@@ -2128,14 +2128,14 @@ namespace ts {
|
||||
: node;
|
||||
}
|
||||
|
||||
export function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block) {
|
||||
export function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block) {
|
||||
const node = <CatchClause>createSynthesizedNode(SyntaxKind.CatchClause);
|
||||
node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration;
|
||||
node.block = block;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block) {
|
||||
export function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block) {
|
||||
return node.variableDeclaration !== variableDeclaration
|
||||
|| node.block !== block
|
||||
? updateNode(createCatchClause(variableDeclaration, block), node)
|
||||
|
||||
@@ -4783,6 +4783,10 @@ namespace ts {
|
||||
result.variableDeclaration = parseVariableDeclaration();
|
||||
parseExpected(SyntaxKind.CloseParenToken);
|
||||
}
|
||||
else {
|
||||
// Keep shape of node to not avoid degrading performance.
|
||||
result.variableDeclaration = undefined;
|
||||
}
|
||||
|
||||
result.block = parseBlock(/*ignoreMissingOpenBrace*/ false);
|
||||
return finishNode(result);
|
||||
|
||||
@@ -3173,7 +3173,7 @@ namespace ts {
|
||||
function visitCatchClause(node: CatchClause): CatchClause {
|
||||
const ancestorFacts = enterSubtree(HierarchyFacts.BlockScopeExcludes, HierarchyFacts.BlockScopeIncludes);
|
||||
let updated: CatchClause;
|
||||
Debug.assert(!!node.variableDeclaration, "Catch clauses should always be present when downleveling ES2015 code.");
|
||||
Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
|
||||
if (isBindingPattern(node.variableDeclaration.name)) {
|
||||
const temp = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
const newVariableDeclaration = createVariableDeclaration(temp);
|
||||
|
||||
@@ -1807,7 +1807,7 @@ namespace ts {
|
||||
|
||||
export interface CatchClause extends Node {
|
||||
kind: SyntaxKind.CatchClause;
|
||||
parent?: TryStatement; // We make this optional to parse missing try statements
|
||||
parent?: TryStatement;
|
||||
variableDeclaration?: VariableDeclaration;
|
||||
block: Block;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user