Skip to content

Commit 8aa62b4

Browse files
committed
Improve yield context error message
1 parent d47f3be commit 8aa62b4

10 files changed

+17
-17
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7897,7 +7897,7 @@ module ts {
78977897
function checkYieldExpression(node: YieldExpression): void {
78987898
// Grammar checking
78997899
if (!(node.parserContextFlags & ParserContextFlags.Yield)) {
7900-
grammarErrorOnFirstToken(node, Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration);
7900+
grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_declaration);
79017901
}
79027902
else {
79037903
grammarErrorOnFirstToken(node, Diagnostics.yield_expressions_are_not_currently_supported);

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ module ts {
120120
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
121121
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
122122
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
123-
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." },
123+
A_yield_expression_is_only_allowed_in_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator declaration." },
124124
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
125125
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." },
126126
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." },

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@
467467
"category": "Error",
468468
"code": 1162
469469
},
470-
"'yield' expression must be contained_within a generator declaration.": {
470+
"A 'yield' expression is only allowed in a generator declaration.": {
471471
"category": "Error",
472472
"code": 1163
473473
},
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
1+
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator declaration.
22

33

44
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ====
55
class C {
66
constructor() {
77
yield foo
88
~~~~~
9-
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
9+
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
1010
}
1111
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
1+
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator declaration.
22

33

44
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ====
55
class C {
66
foo() {
77
yield foo
88
~~~~~
9-
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
9+
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
1010
}
1111
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
1+
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: A 'yield' expression is only allowed in a generator declaration.
22

33

44
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ====
55
var v = () => {
66
yield foo
77
~~~~~
8-
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
8+
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported.
2-
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration.
2+
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator declaration.
33

44

55
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ====
@@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): erro
99
function bar() {
1010
yield foo;
1111
~~~~~
12-
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
12+
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
1313
}
1414
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
22
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
3-
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: 'yield' expression must be contained_within a generator declaration.
3+
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator declaration.
44

55

66
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (3 errors) ====
@@ -10,4 +10,4 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): err
1010
~~~
1111
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
1212
~~~~~
13-
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
13+
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
1+
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator declaration.
22

33

44
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ====
55
"use strict";
66
yield(foo);
77
~~~~~
8-
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
8+
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
1+
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: A 'yield' expression is only allowed in a generator declaration.
22

33

44
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ====
55
yield foo;
66
~~~~~
7-
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
7+
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.

0 commit comments

Comments
 (0)