From 39a6cce78910ef410889f6993408720f4c2284df Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 8 May 2015 21:37:43 -0700 Subject: [PATCH] Cleaned up diagnostic messages --- src/compiler/checker.ts | 5 ++- .../diagnosticInformationMap.generated.ts | 11 +----- src/compiler/diagnosticMessages.json | 38 +------------------ 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d759eb1fc1a..650a65119b6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7635,7 +7635,7 @@ module ts { function checkAwaitExpression(node: AwaitExpression): Type { // Grammar checking if (!(node.parserContextFlags & ParserContextFlags.Await)) { - grammarErrorOnFirstToken(node, Diagnostics.await_expression_must_be_contained_within_an_async_function); + grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function); } let operandType = checkExpression(node.expression); @@ -10069,6 +10069,9 @@ module ts { if (node.parserContextFlags & ParserContextFlags.StrictMode) { grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); } + else if (node.parserContextFlags & ParserContextFlags.Await) { + grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } } checkExpression(node.expression); diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 4a4ae961109..f466d6bfe41 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -181,16 +181,7 @@ module ts { Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." }, with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." }, - _0_modifier_cannot_be_used_with_a_generator: { code: 1301, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a generator." }, - _0_modifier_cannot_be_used_with_a_module_declaration: { code: 1302, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a module declaration." }, - _0_modifier_cannot_be_used_with_an_enum_declaration: { code: 1303, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with an enum declaration." }, - _0_modifier_cannot_be_used_with_an_export_assignment_declaration: { code: 1304, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with an export assignment declaration." }, - _0_modifier_cannot_be_used_on_a_variable_statement: { code: 1305, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used on a variable statement." }, - _0_modifier_cannot_be_used_with_a_type_declaration: { code: 1306, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a type declaration." }, - _0_modifier_cannot_be_used_with_a_parameter_declaration: { code: 1307, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a parameter declaration." }, - await_expression_must_be_contained_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression must be contained within an async function." }, - _0_modifier_cannot_be_used_on_an_object_literal_element: { code: 1309, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used on an object literal element." }, - _0_expression_is_not_allowed_in_an_initializer: { code: 1310, category: DiagnosticCategory.Error, key: "'{0}' expression is not allowed in an initializer." }, + await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index feb7730a8a3..aa8ec55f522 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -712,46 +712,10 @@ "category": "Error", "code": 1300 }, - "'{0}' modifier cannot be used with a generator.": { - "category": "Error", - "code": 1301 - }, - "'{0}' modifier cannot be used with a module declaration.": { - "category": "Error", - "code": 1302 - }, - "'{0}' modifier cannot be used with an enum declaration.": { - "category": "Error", - "code": 1303 - }, - "'{0}' modifier cannot be used with an export assignment declaration.": { - "category": "Error", - "code": 1304 - }, - "'{0}' modifier cannot be used on a variable statement.": { - "category": "Error", - "code": 1305 - }, - "'{0}' modifier cannot be used with a type declaration.": { - "category": "Error", - "code": 1306 - }, - "'{0}' modifier cannot be used with a parameter declaration.": { - "category": "Error", - "code": 1307 - }, - "'await' expression must be contained within an async function.": { + "'await' expression is only allowed within an async function.": { "category": "Error", "code": 1308 }, - "'{0}' modifier cannot be used on an object literal element.": { - "category": "Error", - "code": 1309 - }, - "'{0}' expression is not allowed in an initializer.": { - "category": "Error", - "code": 1310 - }, "Async functions are only available when targeting ECMAScript 6 and higher.": { "category": "Error", "code": 1311