Skip to content

Commit 6c32a6a

Browse files
committed
Address feedback
1 parent 8558d64 commit 6c32a6a

39 files changed

Lines changed: 105 additions & 108 deletions

src/compiler/checker.ts

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8082,7 +8082,7 @@ module ts {
80828082
function checkBlock(node: Block) {
80838083
// Grammar checking for SyntaxKind.Block
80848084
if (node.kind === SyntaxKind.Block) {
8085-
checkGrammarForStatementInAmbientContext(node);
8085+
checkGrammarStatementInAmbientContext(node);
80868086
}
80878087

80888088
forEach(node.statements, checkSourceElement);
@@ -8396,14 +8396,14 @@ module ts {
83968396

83978397
function checkExpressionStatement(node: ExpressionStatement) {
83988398
// Grammar checking
8399-
checkGrammarForStatementInAmbientContext(node)
8399+
checkGrammarStatementInAmbientContext(node)
84008400

84018401
checkExpression(node.expression);
84028402
}
84038403

84048404
function checkIfStatement(node: IfStatement) {
84058405
// Grammar checking
8406-
checkGrammarForStatementInAmbientContext(node);
8406+
checkGrammarStatementInAmbientContext(node);
84078407

84088408
checkExpression(node.expression);
84098409
checkSourceElement(node.thenStatement);
@@ -8412,23 +8412,23 @@ module ts {
84128412

84138413
function checkDoStatement(node: DoStatement) {
84148414
// Grammar checking
8415-
checkGrammarForStatementInAmbientContext(node);
8415+
checkGrammarStatementInAmbientContext(node);
84168416

84178417
checkSourceElement(node.statement);
84188418
checkExpression(node.expression);
84198419
}
84208420

84218421
function checkWhileStatement(node: WhileStatement) {
84228422
// Grammar checking
8423-
checkGrammarForStatementInAmbientContext(node);
8423+
checkGrammarStatementInAmbientContext(node);
84248424

84258425
checkExpression(node.expression);
84268426
checkSourceElement(node.statement);
84278427
}
84288428

84298429
function checkForStatement(node: ForStatement) {
84308430
// Grammar checking
8431-
if (!checkGrammarForStatementInAmbientContext(node)) {
8431+
if (!checkGrammarStatementInAmbientContext(node)) {
84328432
if (node.initializer && node.initializer.kind == SyntaxKind.VariableDeclarationList) {
84338433
checkGrammarVariableDeclarationList(<VariableDeclarationList>node.initializer);
84348434
}
@@ -8497,7 +8497,7 @@ module ts {
84978497

84988498
function checkBreakOrContinueStatement(node: BreakOrContinueStatement) {
84998499
// Grammar checking
8500-
checkGrammarForStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node);
8500+
checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node);
85018501

85028502
// TODO: Check that target label is valid
85038503
}
@@ -8508,7 +8508,7 @@ module ts {
85088508

85098509
function checkReturnStatement(node: ReturnStatement) {
85108510
// Grammar checking
8511-
if (!checkGrammarForStatementInAmbientContext(node)) {
8511+
if (!checkGrammarStatementInAmbientContext(node)) {
85128512
var functionBlock = getContainingFunction(node);
85138513
if (!functionBlock) {
85148514
grammarErrorOnFirstToken(node, Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
@@ -8539,7 +8539,7 @@ module ts {
85398539

85408540
function checkWithStatement(node: WithStatement) {
85418541
// Grammar checking for withStatement
8542-
if (!checkGrammarForStatementInAmbientContext(node)) {
8542+
if (!checkGrammarStatementInAmbientContext(node)) {
85438543
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
85448544
grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode);
85458545
}
@@ -8551,7 +8551,7 @@ module ts {
85518551

85528552
function checkSwitchStatement(node: SwitchStatement) {
85538553
// Grammar checking
8554-
checkGrammarForStatementInAmbientContext(node);
8554+
checkGrammarStatementInAmbientContext(node);
85558555

85568556
var firstDefaultClause: CaseOrDefaultClause;
85578557
var hasDuplicateDefaultClause = false;
@@ -8588,7 +8588,7 @@ module ts {
85888588

85898589
function checkLabeledStatement(node: LabeledStatement) {
85908590
// Grammar checking
8591-
if (!checkGrammarForStatementInAmbientContext(node)) {
8591+
if (!checkGrammarStatementInAmbientContext(node)) {
85928592
var current = node.parent;
85938593
while (current) {
85948594
if (isAnyFunction(current)) {
@@ -8609,7 +8609,7 @@ module ts {
86098609

86108610
function checkThrowStatement(node: ThrowStatement) {
86118611
// Grammar checking
8612-
if (!checkGrammarForStatementInAmbientContext(node)) {
8612+
if (!checkGrammarStatementInAmbientContext(node)) {
86138613
if (node.expression === undefined) {
86148614
grammarErrorAfterFirstToken(node, Diagnostics.Line_break_not_permitted_here);
86158615
}
@@ -8622,7 +8622,7 @@ module ts {
86228622

86238623
function checkTryStatement(node: TryStatement) {
86248624
// Grammar checking
8625-
checkGrammarForStatementInAmbientContext(node);
8625+
checkGrammarStatementInAmbientContext(node);
86268626

86278627
checkBlock(node.tryBlock);
86288628
var catchClause = node.catchClause;
@@ -9480,10 +9480,10 @@ module ts {
94809480
case SyntaxKind.ExportAssignment:
94819481
return checkExportAssignment(<ExportAssignment>node);
94829482
case SyntaxKind.EmptyStatement:
9483-
checkGrammarForStatementInAmbientContext(node);
9483+
checkGrammarStatementInAmbientContext(node);
94849484
return;
94859485
case SyntaxKind.DebuggerStatement:
9486-
checkGrammarForStatementInAmbientContext(node);
9486+
checkGrammarStatementInAmbientContext(node);
94879487
return;
94889488
}
94899489
}
@@ -10753,30 +10753,30 @@ module ts {
1075310753
}
1075410754

1075510755
function checkGrammarForInOrForOfStatement(forInOrOfStatement: ForInStatement | ForOfStatement): boolean {
10756-
if (checkGrammarForStatementInAmbientContext(forInOrOfStatement)) {
10756+
if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
1075710757
return true;
1075810758
}
1075910759

1076010760
if (forInOrOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
1076110761
var variableList = <VariableDeclarationList>forInOrOfStatement.initializer;
1076210762
if (!checkGrammarVariableDeclarationList(variableList)) {
1076310763
if (variableList.declarations.length > 1) {
10764-
var diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ?
10765-
Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement :
10766-
Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
10764+
var diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement
10765+
? Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
10766+
: Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
1076710767
return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
1076810768
}
1076910769
var firstDeclaration = variableList.declarations[0];
1077010770
if (firstDeclaration.initializer) {
10771-
var diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ?
10772-
Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer :
10773-
Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
10771+
var diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement
10772+
? Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
10773+
: Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
1077410774
return grammarErrorOnNode(firstDeclaration.name, diagnostic);
1077510775
}
1077610776
if (firstDeclaration.type) {
10777-
var diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement ?
10778-
Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation :
10779-
Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
10777+
var diagnostic = forInOrOfStatement.kind === SyntaxKind.ForInStatement
10778+
? Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
10779+
: Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
1078010780
return grammarErrorOnNode(firstDeclaration, diagnostic);
1078110781
}
1078210782
}
@@ -10787,15 +10787,12 @@ module ts {
1078710787

1078810788
function checkGrammarForOfStatement(forOfStatement: ForOfStatement): boolean {
1078910789
// Temporarily disallow for-of statements until type check work is complete.
10790-
return grammarErrorOnFirstToken(forOfStatement, Diagnostics.For_of_statements_are_not_currently_supported);
10791-
if (checkGrammarForInOrForOfStatement(forOfStatement)) {
10792-
return true;
10793-
}
10790+
return grammarErrorOnFirstToken(forOfStatement, Diagnostics.for_of_statements_are_not_currently_supported);
1079410791
if (languageVersion < ScriptTarget.ES6) {
10795-
return grammarErrorOnFirstToken(forOfStatement, Diagnostics.For_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher);
10792+
return grammarErrorOnFirstToken(forOfStatement, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher);
1079610793
}
1079710794

10798-
return false;
10795+
return checkGrammarForInOrForOfStatement(forOfStatement);
1079910796
}
1080010797

1080110798
function checkGrammarAccessor(accessor: MethodDeclaration): boolean {
@@ -11235,7 +11232,7 @@ module ts {
1123511232
return isInAmbientContext(node) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
1123611233
}
1123711234

11238-
function checkGrammarForStatementInAmbientContext(node: Node): boolean {
11235+
function checkGrammarStatementInAmbientContext(node: Node): boolean {
1123911236
if (isInAmbientContext(node)) {
1124011237
// An accessors is already reported about the ambient context
1124111238
if (isAccessor(node.parent.kind)) {

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ module ts {
316316
Property_0_does_not_exist_on_const_enum_1: { code: 2475, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
317317
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2476, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
318318
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2477, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
319-
For_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "For...of statements are only available when targeting ECMAScript 6 or higher." },
319+
for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." },
320320
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." },
321321
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
322322
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -463,6 +463,6 @@ module ts {
463463
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
464464
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
465465
The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." },
466-
For_of_statements_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "For...of statements are not currently supported." },
466+
for_of_statements_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'for...of' statements are not currently supported." },
467467
};
468468
}

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@
12561256
"category": "Error",
12571257
"code": 2477
12581258
},
1259-
"For...of statements are only available when targeting ECMAScript 6 or higher.": {
1259+
"'for...of' statements are only available when targeting ECMAScript 6 or higher.": {
12601260
"category": "Error",
12611261
"code": 2482
12621262
},
@@ -1846,7 +1846,7 @@
18461846
"category": "Error",
18471847
"code": 9002
18481848
},
1849-
"For...of statements are not currently supported.": {
1849+
"'for...of' statements are not currently supported.": {
18501850
"category": "Error",
18511851
"code": 9003
18521852
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts(1,1): error TS9003: For...of statements are not currently supported.
1+
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts(1,1): error TS9003: 'for...of' statements are not currently supported.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement1.d.ts (1 errors) ====
55
for (var i of e) {
66
~~~
7-
!!! error TS9003: For...of statements are not currently supported.
7+
!!! error TS9003: 'for...of' statements are not currently supported.
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts(1,1): error TS9003: For...of statements are not currently supported.
1+
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts(1,1): error TS9003: 'for...of' statements are not currently supported.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement10.ts (1 errors) ====
55
for (const v of X) {
66
~~~
7-
!!! error TS9003: For...of statements are not currently supported.
7+
!!! error TS9003: 'for...of' statements are not currently supported.
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts(1,1): error TS9003: For...of statements are not currently supported.
1+
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts(1,1): error TS9003: 'for...of' statements are not currently supported.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement11.ts (1 errors) ====
55
for (const [a, b] of X) {
66
~~~
7-
!!! error TS9003: For...of statements are not currently supported.
7+
!!! error TS9003: 'for...of' statements are not currently supported.
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts(1,1): error TS9003: For...of statements are not currently supported.
1+
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts(1,1): error TS9003: 'for...of' statements are not currently supported.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement12.ts (1 errors) ====
55
for (const {a, b} of X) {
66
~~~
7-
!!! error TS9003: For...of statements are not currently supported.
7+
!!! error TS9003: 'for...of' statements are not currently supported.
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts(1,1): error TS9003: For...of statements are not currently supported.
1+
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts(1,1): error TS9003: 'for...of' statements are not currently supported.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement13.ts (1 errors) ====
55
for (let {a, b} of X) {
66
~~~
7-
!!! error TS9003: For...of statements are not currently supported.
7+
!!! error TS9003: 'for...of' statements are not currently supported.
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts(1,1): error TS9003: For...of statements are not currently supported.
1+
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts(1,1): error TS9003: 'for...of' statements are not currently supported.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement14.ts (1 errors) ====
55
for (let [a, b] of X) {
66
~~~
7-
!!! error TS9003: For...of statements are not currently supported.
7+
!!! error TS9003: 'for...of' statements are not currently supported.
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts(1,1): error TS9003: For...of statements are not currently supported.
1+
tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts(1,1): error TS9003: 'for...of' statements are not currently supported.
22

33

44
==== tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement15.ts (1 errors) ====
55
for (var [a, b] of X) {
66
~~~
7-
!!! error TS9003: For...of statements are not currently supported.
7+
!!! error TS9003: 'for...of' statements are not currently supported.
88
}

0 commit comments

Comments
 (0)