mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
set 'earlyError' bit to 'non-constant expression in constant enum initializer' error
This commit is contained in:
parent
dd57c6c5c0
commit
ac54fbfa46
@ -351,7 +351,7 @@ module ts {
|
||||
Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." },
|
||||
Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." },
|
||||
Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
|
||||
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." },
|
||||
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true },
|
||||
const_enums_can_only_be_used_in_property_access_Slashindex_access_expressions_and_as_right_hand_side_in_import_declarations_Slashexport_assignments: { code: 4084, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property access/index access expressions and as right hand side in import declarations/export assignments." },
|
||||
Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'." },
|
||||
const_enum_member_initializer_was_evaluated_to_a_non_finite_number: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite number." },
|
||||
|
||||
@ -1407,7 +1407,8 @@
|
||||
},
|
||||
"In 'const' enum declarations member initializer must be constant expression.": {
|
||||
"category": "Error",
|
||||
"code": 4083
|
||||
"code": 4083,
|
||||
"isEarly": true
|
||||
},
|
||||
"'const' enums can only be used in property access/index access expressions and as right hand side in import declarations/export assignments.": {
|
||||
"category": "Error",
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
//// [constEnumErrors.ts]
|
||||
const enum E {
|
||||
A
|
||||
}
|
||||
|
||||
module E {
|
||||
var x = 1;
|
||||
}
|
||||
|
||||
const enum E1 {
|
||||
// illegal case
|
||||
// forward reference to the element of the same enum
|
||||
X = Y,
|
||||
// forward reference to the element of the same enum
|
||||
Y = E1.Z,
|
||||
Y1 = E1["Z"]
|
||||
}
|
||||
|
||||
const enum E2 {
|
||||
A
|
||||
}
|
||||
|
||||
var y0 = E2[1]
|
||||
var name = "A";
|
||||
var y1 = E2[name];
|
||||
|
||||
var x = E2;
|
||||
var y = [E2];
|
||||
|
||||
function foo(t: any): void {
|
||||
}
|
||||
|
||||
foo(E2);
|
||||
|
||||
const enum NaNOrInfinity {
|
||||
A = 9007199254740992,
|
||||
B = A * A,
|
||||
C = B * B,
|
||||
D = C * C,
|
||||
E = D * D,
|
||||
F = E * E, // overflow
|
||||
G = 1 / 0, // overflow
|
||||
H = 0 / 0 // NaN
|
||||
}
|
||||
|
||||
//// [constEnumErrors.js]
|
||||
var E;
|
||||
(function (E) {
|
||||
var x = 1;
|
||||
})(E || (E = {}));
|
||||
var y0 = E2[1];
|
||||
var name = "A";
|
||||
var y1 = E2[name];
|
||||
var x = E2;
|
||||
var y = [E2];
|
||||
function foo(t) {
|
||||
}
|
||||
foo(E2);
|
||||
Loading…
x
Reference in New Issue
Block a user