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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(9,1): error TS2322: Type 'F' is not assignable to type 'E'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(10,1): error TS2322: Type 'E' is not assignable to type 'F'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(29,9): error TS2322: Type 'E' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(30,9): error TS2322: Type 'E' is not assignable to type 'boolean'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(31,9): error TS2322: Type 'E' is not assignable to type 'Date'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(33,9): error TS2322: Type 'E' is not assignable to type 'void'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(36,9): error TS2322: Type 'E' is not assignable to type '() => {}'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(37,9): error TS2322: Type 'E' is not assignable to type 'Function'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(38,9): error TS2322: Type 'E' is not assignable to type '(x: number) => string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(39,5): error TS2322: Type 'E' is not assignable to type 'C'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(40,5): error TS2322: Type 'E' is not assignable to type 'I'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(41,9): error TS2322: Type 'E' is not assignable to type 'number[]'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(42,9): error TS2322: Type 'E' is not assignable to type '{ foo: string; }'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(43,9): error TS2322: Type 'E' is not assignable to type '<T>(x: T) => T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(45,9): error TS2322: Type 'E' is not assignable to type 'String'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(48,9): error TS2322: Type 'E' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'E'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(49,9): error TS2322: Type 'E' is not assignable to type 'U'.
'U' could be instantiated with an arbitrary type which could be unrelated to 'E'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(50,9): error TS2322: Type 'E' is not assignable to type 'V'.
'V' could be instantiated with an arbitrary type which could be unrelated to 'E'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(51,13): error TS2322: Type 'E' is not assignable to type 'A'.
'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(52,13): error TS2322: Type 'E' is not assignable to type 'B'.
'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts (20 errors) ====
// enums assignable to number, any, Object, errors unless otherwise noted
enum E { A }
enum F { B }
var e = E.A;
var f = F.B;
e = f;
~
!!! error TS2322: Type 'F' is not assignable to type 'E'.
f = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'F'.
e = 1; // ok
f = 1; // ok
var x: number = e; // ok
x = f; // ok
module Others {
var a: any = e; // ok
class C {
foo: string;
}
var ac: C;
interface I {
foo: string;
}
var ai: I;
var b: number = e; // ok
var c: string = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'string'.
var d: boolean = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'boolean'.
var ee: Date = e;
~~
!!! error TS2322: Type 'E' is not assignable to type 'Date'.
var f: any = e; // ok
var g: void = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'void'.
var h: Object = e;
var i: {} = e;
var j: () => {} = e;
~
!!! error TS2322: Type 'E' is not assignable to type '() => {}'.
var k: Function = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'Function'.
var l: (x: number) => string = e;
~
!!! error TS2322: Type 'E' is not assignable to type '(x: number) => string'.
ac = e;
~~
!!! error TS2322: Type 'E' is not assignable to type 'C'.
ai = e;
~~
!!! error TS2322: Type 'E' is not assignable to type 'I'.
var m: number[] = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'number[]'.
var n: { foo: string } = e;
~
!!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }'.
var o: <T>(x: T) => T = e;
~
!!! error TS2322: Type 'E' is not assignable to type '<T>(x: T) => T'.
var p: Number = e;
var q: String = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'String'.
function foo<T, U extends T, V extends Date, A extends Number, B extends E>(x: T, y: U, z: V) {
x = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'T'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'E'.
y = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'U'.
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'E'.
z = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'V'.
!!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'E'.
var a: A = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'A'.
!!! error TS2322: 'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'.
var b: B = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'B'.
!!! error TS2322: 'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'.
}
}
|