85 lines
4.1 KiB
Plaintext
85 lines
4.1 KiB
Plaintext
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'.
|
|
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'.
|
|
tests/cases/compiler/constEnumErrors.ts(12,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
|
tests/cases/compiler/constEnumErrors.ts(14,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
|
tests/cases/compiler/constEnumErrors.ts(15,10): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
|
tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: A const enum member can only be accessed using a string literal.
|
|
tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: A const enum member can only be accessed using a string literal.
|
|
tests/cases/compiler/constEnumErrors.ts(26,9): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
|
tests/cases/compiler/constEnumErrors.ts(27,10): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
|
tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
|
tests/cases/compiler/constEnumErrors.ts(40,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
|
tests/cases/compiler/constEnumErrors.ts(41,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
|
tests/cases/compiler/constEnumErrors.ts(42,9): error TS4087: 'const' enum member initializer was evaluated to disallowed value 'NaN'.
|
|
|
|
|
|
==== tests/cases/compiler/constEnumErrors.ts (13 errors) ====
|
|
const enum E {
|
|
~
|
|
!!! error TS2300: Duplicate identifier 'E'.
|
|
A
|
|
}
|
|
|
|
module E {
|
|
~
|
|
!!! error TS2300: Duplicate identifier 'E'.
|
|
var x = 1;
|
|
}
|
|
|
|
const enum E1 {
|
|
// illegal case
|
|
// forward reference to the element of the same enum
|
|
X = Y,
|
|
~
|
|
!!! error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
|
// forward reference to the element of the same enum
|
|
Y = E1.Z,
|
|
~~~~
|
|
!!! error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
|
Y1 = E1["Z"]
|
|
~~~~~~~
|
|
!!! error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
|
}
|
|
|
|
const enum E2 {
|
|
A
|
|
}
|
|
|
|
var y0 = E2[1]
|
|
~
|
|
!!! error TS4085: A const enum member can only be accessed using a string literal.
|
|
var name = "A";
|
|
var y1 = E2[name];
|
|
~~~~
|
|
!!! error TS4085: A const enum member can only be accessed using a string literal.
|
|
|
|
var x = E2;
|
|
~~
|
|
!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
|
var y = [E2];
|
|
~~
|
|
!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
|
|
|
function foo(t: any): void {
|
|
}
|
|
|
|
foo(E2);
|
|
~~
|
|
!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
|
|
|
const enum NaNOrInfinity {
|
|
A = 9007199254740992,
|
|
B = A * A,
|
|
C = B * B,
|
|
D = C * C,
|
|
E = D * D,
|
|
F = E * E, // overflow
|
|
~~~~~
|
|
!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
|
G = 1 / 0, // overflow
|
|
~~~~~
|
|
!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
|
H = 0 / 0 // NaN
|
|
~~~~~
|
|
!!! error TS4087: 'const' enum member initializer was evaluated to disallowed value 'NaN'.
|
|
} |