2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/conformance/enums/enumErrors.ts (11 errors) ====
|
|
|
|
// Enum named with PredefinedTypes
|
|
|
|
enum any { }
|
|
|
|
~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2431: Enum name cannot be 'any'
|
2014-07-13 01:04:16 +02:00
|
|
|
enum number { }
|
|
|
|
~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2431: Enum name cannot be 'number'
|
2014-07-13 01:04:16 +02:00
|
|
|
enum string { }
|
|
|
|
~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2431: Enum name cannot be 'string'
|
2014-07-13 01:04:16 +02:00
|
|
|
enum boolean { }
|
|
|
|
~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2431: Enum name cannot be 'boolean'
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
// Enum with computed member initializer of type Number
|
|
|
|
enum E5 {
|
|
|
|
C = new Number(30)
|
|
|
|
~~~~~~~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'Number' is not assignable to type 'E5'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
enum E9 {
|
|
|
|
A,
|
|
|
|
B = A
|
|
|
|
}
|
|
|
|
|
|
|
|
//Enum with computed member intializer of different enum type
|
|
|
|
// Bug 707850: This should be allowed
|
|
|
|
enum E10 {
|
|
|
|
A = E9.A,
|
|
|
|
~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'E9' is not assignable to type 'E10'.
|
2014-07-13 01:04:16 +02:00
|
|
|
B = E9.B
|
|
|
|
~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'E9' is not assignable to type 'E10'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Enum with computed member intializer of other types
|
|
|
|
enum E11 {
|
|
|
|
A = '',
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'string' is not assignable to type 'E11'.
|
2014-07-13 01:04:16 +02:00
|
|
|
B = new Date(),
|
|
|
|
~~~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type 'Date' is not assignable to type 'E11'.
|
2014-07-13 01:04:16 +02:00
|
|
|
C = window,
|
|
|
|
~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2304: Cannot find name 'window'.
|
2014-07-13 01:04:16 +02:00
|
|
|
D = {}
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2323: Type '{}' is not assignable to type 'E11'.
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
|