Skip to content

Commit 81fb3f7

Browse files
committed
Addresses CR feedback
1 parent 58c8a2c commit 81fb3f7

7 files changed

Lines changed: 5 additions & 24 deletions

File tree

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2924,7 +2924,7 @@ namespace ts {
29242924
if (!node.variableDeclaration) {
29252925
transformFlags |= TransformFlags.AssertESNext;
29262926
}
2927-
else if (/* node.variableDeclaration && */ isBindingPattern(node.variableDeclaration.name)) {
2927+
else if (isBindingPattern(node.variableDeclaration.name)) {
29282928
transformFlags |= TransformFlags.AssertES2015;
29292929
}
29302930

src/compiler/checker.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20885,17 +20885,6 @@ namespace ts {
2088520885
}
2088620886
}
2088720887
}
20888-
else if (/* !catchClause.variableDeclaration && */ languageVersion < ScriptTarget.ESNext) {
20889-
const blockLocals = catchClause.block.locals;
20890-
if (blockLocals) {
20891-
forEachKey(blockLocals, caughtName => {
20892-
if (caughtName === "_ignoredCatchParameter") {
20893-
const localSymbol = blockLocals.get(caughtName);
20894-
grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_ignoredCatchParameter_Compiler_uses_the_parameter_declaration_ignoredCatchParameter_to_bind_ignored_catched_exceptions);
20895-
}
20896-
});
20897-
}
20898-
}
2089920888

2090020889
checkBlock(catchClause.block);
2090120890
}

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,10 +2196,6 @@
21962196
"category": "Error",
21972197
"code": 2713
21982198
},
2199-
"Duplicate identifier '_ignoredCatchParameter'. Compiler uses the parameter declaration '_ignoredCatchParameter' to bind ignored catched exceptions.": {
2200-
"category": "Error",
2201-
"code": 2714
2202-
},
22032199

22042200
"Import declaration '{0}' is using private name '{1}'.": {
22052201
"category": "Error",

src/compiler/transformers/es2015.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3173,7 +3173,8 @@ namespace ts {
31733173
function visitCatchClause(node: CatchClause): CatchClause {
31743174
const ancestorFacts = enterSubtree(HierarchyFacts.BlockScopeExcludes, HierarchyFacts.BlockScopeIncludes);
31753175
let updated: CatchClause;
3176-
if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) {
3176+
Debug.assert(!!node.variableDeclaration, "Catch clauses should always be present when downleveling ES2015 code.");
3177+
if (isBindingPattern(node.variableDeclaration.name)) {
31773178
const temp = createTempVariable(/*recordTempVariable*/ undefined);
31783179
const newVariableDeclaration = createVariableDeclaration(temp);
31793180
setTextRange(newVariableDeclaration, node.variableDeclaration);

src/compiler/transformers/esnext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ namespace ts {
216216

217217
function visitCatchClause(node: CatchClause): CatchClause {
218218
if (!node.variableDeclaration) {
219-
return updateCatchClause(node, createVariableDeclaration("_ignoredCatchParameter"), node.block);
219+
return updateCatchClause(node, createVariableDeclaration(createTempVariable(/*recordTempVariable*/ undefined)), node.block);
220220
}
221221
return visitEachChild(node, visitor, context);
222222
}

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ namespace ts {
18071807

18081808
export interface CatchClause extends Node {
18091809
kind: SyntaxKind.CatchClause;
1810-
parent?: TryStatement; // We parse missing try statements
1810+
parent?: TryStatement; // We make this optional to parse missing try statements
18111811
variableDeclaration?: VariableDeclaration;
18121812
block: Block;
18131813
}

tests/cases/conformance/statements/tryStatements/invalidTryStatements.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,5 @@ function fn() {
88
try { } catch (z: any) { }
99
try { } catch (a: number) { }
1010
try { } catch (y: string) { }
11-
12-
13-
try { } catch {
14-
let _ignoredCatchParameter; // Should error since we downlevel emit this variable.
15-
}
1611
}
1712

0 commit comments

Comments
 (0)