File: constEnum2.errors.txt

package info (click to toggle)
node-typescript 4.8.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 523,068 kB
  • sloc: javascript: 1,735,777; makefile: 7; sh: 1
file content (28 lines) | stat: -rw-r--r-- 1,820 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
tests/cases/conformance/constEnums/constEnum2.ts(10,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
tests/cases/conformance/constEnums/constEnum2.ts(11,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.
tests/cases/conformance/constEnums/constEnum2.ts(12,5): error TS1357: An enum member name must be followed by a ',', '=', or '}'.
tests/cases/conformance/constEnums/constEnum2.ts(12,9): error TS2474: const enum member initializers can only contain literal values and other computed enum values.


==== tests/cases/conformance/constEnums/constEnum2.ts (4 errors) ====
    // An enum declaration that specifies a const modifier is a constant enum declaration.
    // In a constant enum declaration, all members must have constant values and
    // it is an error for a member declaration to specify an expression that isn't classified as a constant enum expression.
    
    // Error : not a constant enum expression
    
    const CONST = 9000 % 2;
    const enum D {
        d = 10,
        e = 199 * Math.floor(Math.random() * 1000),
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
        f = d - (100 * Math.floor(Math.random() % 8))
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
        g = CONST,
        ~
!!! error TS1357: An enum member name must be followed by a ',', '=', or '}'.
            ~~~~~
!!! error TS2474: const enum member initializers can only contain literal values and other computed enum values.
    }