Addresses CR feedback

This commit is contained in:
Tingan Ho 2017-08-01 22:10:12 +02:00
parent 58c8a2c03d
commit 81fb3f702a
7 changed files with 5 additions and 24 deletions

View file

@ -2924,7 +2924,7 @@ namespace ts {
if (!node.variableDeclaration) {
transformFlags |= TransformFlags.AssertESNext;
}
else if (/* node.variableDeclaration && */ isBindingPattern(node.variableDeclaration.name)) {
else if (isBindingPattern(node.variableDeclaration.name)) {
transformFlags |= TransformFlags.AssertES2015;
}

View file

@ -20885,17 +20885,6 @@ namespace ts {
}
}
}
else if (/* !catchClause.variableDeclaration && */ languageVersion < ScriptTarget.ESNext) {
const blockLocals = catchClause.block.locals;
if (blockLocals) {
forEachKey(blockLocals, caughtName => {
if (caughtName === "_ignoredCatchParameter") {
const localSymbol = blockLocals.get(caughtName);
grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_ignoredCatchParameter_Compiler_uses_the_parameter_declaration_ignoredCatchParameter_to_bind_ignored_catched_exceptions);
}
});
}
}
checkBlock(catchClause.block);
}

View file

@ -2196,10 +2196,6 @@
"category": "Error",
"code": 2713
},
"Duplicate identifier '_ignoredCatchParameter'. Compiler uses the parameter declaration '_ignoredCatchParameter' to bind ignored catched exceptions.": {
"category": "Error",
"code": 2714
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",

View file

@ -3173,7 +3173,8 @@ namespace ts {
function visitCatchClause(node: CatchClause): CatchClause {
const ancestorFacts = enterSubtree(HierarchyFacts.BlockScopeExcludes, HierarchyFacts.BlockScopeIncludes);
let updated: CatchClause;
if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) {
Debug.assert(!!node.variableDeclaration, "Catch clauses should always be present when downleveling ES2015 code.");
if (isBindingPattern(node.variableDeclaration.name)) {
const temp = createTempVariable(/*recordTempVariable*/ undefined);
const newVariableDeclaration = createVariableDeclaration(temp);
setTextRange(newVariableDeclaration, node.variableDeclaration);

View file

@ -216,7 +216,7 @@ namespace ts {
function visitCatchClause(node: CatchClause): CatchClause {
if (!node.variableDeclaration) {
return updateCatchClause(node, createVariableDeclaration("_ignoredCatchParameter"), node.block);
return updateCatchClause(node, createVariableDeclaration(createTempVariable(/*recordTempVariable*/ undefined)), node.block);
}
return visitEachChild(node, visitor, context);
}

View file

@ -1807,7 +1807,7 @@ namespace ts {
export interface CatchClause extends Node {
kind: SyntaxKind.CatchClause;
parent?: TryStatement; // We parse missing try statements
parent?: TryStatement; // We make this optional to parse missing try statements
variableDeclaration?: VariableDeclaration;
block: Block;
}

View file

@ -8,10 +8,5 @@ function fn() {
try { } catch (z: any) { }
try { } catch (a: number) { }
try { } catch (y: string) { }
try { } catch {
let _ignoredCatchParameter; // Should error since we downlevel emit this variable.
}
}