mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Update error messages
This commit is contained in:
parent
0e7d8b62ef
commit
dd5c89d5cf
@ -118,9 +118,9 @@ module ts {
|
||||
var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." },
|
||||
let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_must_be_intialized: { code: 1155, category: DiagnosticCategory.Error, key: "const must be intialized." },
|
||||
const_declarations_must_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations must be declared inside a block." },
|
||||
let_declarations_must_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations must be declared inside a block." },
|
||||
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" },
|
||||
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." },
|
||||
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." },
|
||||
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." },
|
||||
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
|
||||
|
||||
@ -463,15 +463,15 @@
|
||||
"category": "Error",
|
||||
"code": 1154
|
||||
},
|
||||
"const must be intialized.": {
|
||||
"'const' declarations must be initialized": {
|
||||
"category": "Error",
|
||||
"code": 1155
|
||||
},
|
||||
"'const' declarations must be declared inside a block.": {
|
||||
"'const' declarations can only be declared inside a block.": {
|
||||
"category": "Error",
|
||||
"code": 1156
|
||||
},
|
||||
"'let' declarations must be declared inside a block.": {
|
||||
"'let' declarations can only be declared inside a block.": {
|
||||
"category": "Error",
|
||||
"code": 1157
|
||||
},
|
||||
|
||||
@ -2726,13 +2726,13 @@ module ts {
|
||||
parseExpected(SyntaxKind.OpenParenToken);
|
||||
if (token !== SyntaxKind.SemicolonToken) {
|
||||
if (parseOptional(SyntaxKind.VarKeyword)) {
|
||||
var declarations = parseVariableDeclarationList(0, true);
|
||||
var declarations = parseVariableDeclarationList(0, /*noIn*/ true);
|
||||
if (!declarations.length) {
|
||||
error(Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||
}
|
||||
}
|
||||
else if (parseOptional(SyntaxKind.LetKeyword)) {
|
||||
var declarations = parseVariableDeclarationList(NodeFlags.Let, true);
|
||||
var declarations = parseVariableDeclarationList(NodeFlags.Let, /*noIn*/ true);
|
||||
if (!declarations.length) {
|
||||
error(Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||
}
|
||||
@ -2741,7 +2741,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
else if (parseOptional(SyntaxKind.ConstKeyword)) {
|
||||
var declarations = parseVariableDeclarationList(NodeFlags.Const, true);
|
||||
var declarations = parseVariableDeclarationList(NodeFlags.Const, /*noIn*/ true);
|
||||
if (!declarations.length) {
|
||||
error(Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||
}
|
||||
@ -3200,7 +3200,7 @@ module ts {
|
||||
grammarErrorAtPos(initializerStart, initializerFirstTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
||||
}
|
||||
if (!inAmbientContext && !node.initializer && flags & NodeFlags.Const) {
|
||||
grammarErrorOnNode(node, Diagnostics.const_must_be_intialized);
|
||||
grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized);
|
||||
}
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
// It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code
|
||||
@ -3245,10 +3245,10 @@ module ts {
|
||||
}
|
||||
else if (!allowLetAndConstDeclarations) {
|
||||
if (node.flags & NodeFlags.Let) {
|
||||
grammarErrorOnNode(node, Diagnostics.let_declarations_must_be_declared_inside_a_block);
|
||||
grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
|
||||
}
|
||||
else if (node.flags & NodeFlags.Const) {
|
||||
grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_declared_inside_a_block);
|
||||
grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
tests/cases/compiler/constDeclarations-errors.ts(3,7): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(4,7): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,7): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(8,11): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(14,11): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: const must be intialized.
|
||||
tests/cases/compiler/constDeclarations-errors.ts(3,7): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(4,7): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,7): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(8,11): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(14,11): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(17,20): error TS1155: 'const' declarations must be initialized
|
||||
tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The operand of an increment or decrement operator cannot be a constant.
|
||||
|
||||
|
||||
@ -15,24 +15,24 @@ tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The opera
|
||||
// error, missing intialicer
|
||||
const c1;
|
||||
~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
const c2: number;
|
||||
~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
const c3, c4, c5 :string, c6; // error, missing initialicer
|
||||
~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
|
||||
// error, can not be unintalized
|
||||
for(const c in {}) { }
|
||||
~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
|
||||
// error, assigning to a const
|
||||
for(const c8 = 0; c8 < 1; c8++) { }
|
||||
@ -42,9 +42,9 @@ tests/cases/compiler/constDeclarations-errors.ts(11,27): error TS2449: The opera
|
||||
// error, can not be unintalized
|
||||
for(const c9; c9 < 1;) { }
|
||||
~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
|
||||
// error, can not be unintalized
|
||||
for(const c10 = 0, c11; c10 < 1;) { }
|
||||
~~~
|
||||
!!! error TS1155: const must be intialized.
|
||||
!!! error TS1155: 'const' declarations must be initialized
|
||||
@ -1,12 +1,12 @@
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(4,5): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(6,5): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(9,5): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(12,5): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(17,5): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(20,5): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(23,5): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(26,12): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: 'const' declarations must be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(4,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(6,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(9,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(12,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(17,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(20,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(23,5): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(26,12): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(29,29): error TS1156: 'const' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/constDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'.
|
||||
|
||||
|
||||
@ -16,21 +16,21 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(16,7): error TS2410: A
|
||||
if (true)
|
||||
const c1 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
else
|
||||
const c2 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
while (true)
|
||||
const c3 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
do
|
||||
const c4 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
while (true);
|
||||
|
||||
var obj;
|
||||
@ -39,27 +39,27 @@ tests/cases/compiler/constDeclarations-invalidContexts.ts(16,7): error TS2410: A
|
||||
!!! error TS2410: All symbols within a 'with' block will be resolved to 'any'.
|
||||
const c5 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
const c6 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
for (var i2 in {})
|
||||
const c7 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
if (true)
|
||||
label: const c8 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
while (false)
|
||||
label2: label3: label4: const c9 = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1156: 'const' declarations must be declared inside a block.
|
||||
!!! error TS1156: 'const' declarations can only be declared inside a block.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(4,5): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(6,5): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(9,5): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(12,5): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(17,5): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(20,5): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(23,5): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(26,12): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'let' declarations must be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(4,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(6,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(9,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(12,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(17,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(20,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(23,5): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(26,12): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(29,29): error TS1157: 'let' declarations can only be declared inside a block.
|
||||
tests/cases/compiler/letDeclarations-invalidContexts.ts(16,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'.
|
||||
|
||||
|
||||
@ -16,21 +16,21 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(16,7): error TS2410: All
|
||||
if (true)
|
||||
let l1 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
else
|
||||
let l2 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
|
||||
while (true)
|
||||
let l3 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
|
||||
do
|
||||
let l4 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
while (true);
|
||||
|
||||
var obj;
|
||||
@ -39,27 +39,27 @@ tests/cases/compiler/letDeclarations-invalidContexts.ts(16,7): error TS2410: All
|
||||
!!! error TS2410: All symbols within a 'with' block will be resolved to 'any'.
|
||||
let l5 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
let l6 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
|
||||
for (var i2 in {})
|
||||
let l7 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
|
||||
if (true)
|
||||
label: let l8 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
|
||||
while (false)
|
||||
label2: label3: label4: let l9 = 0;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1157: 'let' declarations must be declared inside a block.
|
||||
!!! error TS1157: 'let' declarations can only be declared inside a block.
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user