mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Clarify error message
This commit is contained in:
parent
cb198aa7f2
commit
63d2313244
@ -8044,7 +8044,7 @@ module ts {
|
||||
function checkYieldExpression(node: YieldExpression): Type {
|
||||
// Grammar checking
|
||||
if (!(node.parserContextFlags & ParserContextFlags.Yield) || isYieldExpressionInClass(node)) {
|
||||
grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_declaration);
|
||||
grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
|
||||
}
|
||||
|
||||
if (node.expression) {
|
||||
|
||||
@ -120,7 +120,7 @@ module ts {
|
||||
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
|
||||
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
|
||||
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
|
||||
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." },
|
||||
A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." },
|
||||
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
|
||||
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." },
|
||||
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." },
|
||||
|
||||
@ -467,7 +467,7 @@
|
||||
"category": "Error",
|
||||
"code": 1162
|
||||
},
|
||||
"A 'yield' expression is only allowed in a generator declaration.": {
|
||||
"A 'yield' expression is only allowed in a generator body.": {
|
||||
"category": "Error",
|
||||
"code": 1163
|
||||
},
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ====
|
||||
@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): erro
|
||||
constructor() {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ====
|
||||
@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): erro
|
||||
foo() {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ====
|
||||
var v = () => {
|
||||
yield foo
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS1219: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== 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
|
||||
function bar() {
|
||||
yield foo;
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
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.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== 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
|
||||
~~~
|
||||
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ====
|
||||
"use strict";
|
||||
yield(foo);
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ====
|
||||
yield foo;
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts(2,29): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts(2,29): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck32.ts (1 errors) ====
|
||||
var s: string;
|
||||
var f: () => number = () => yield s;
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts(2,19): error TS9003: 'class' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts (2 errors) ====
|
||||
@ -9,7 +9,7 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck56.ts(3,11): erro
|
||||
!!! error TS9003: 'class' expressions are not currently supported.
|
||||
*[yield 0]() {
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
yield 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck57.ts(2,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck57.ts(3,13): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck57.ts(3,13): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck57.ts (2 errors) ====
|
||||
@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck57.ts(3,13): erro
|
||||
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
|
||||
x = yield 0;
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
};
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck58.ts(2,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck58.ts(3,20): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck58.ts(3,20): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck58.ts (2 errors) ====
|
||||
@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck58.ts(3,20): erro
|
||||
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
|
||||
static x = yield 0;
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
};
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(2,11): error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(3,11): error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts (2 errors) ====
|
||||
@ -9,7 +9,7 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck59.ts(3,11): erro
|
||||
!!! error TS9004: 'class' declarations are only supported directly inside a module or as a top level declaration.
|
||||
@(yield "")
|
||||
~~~~~
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator declaration.
|
||||
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
|
||||
m() { }
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user