/
enumAssignabilityInInheritance.errors.txt
120 lines (81 loc) · 3.9 KB
/
enumAssignabilityInInheritance.errors.txt
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
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignabilityInInheritance.ts(104,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'E', but here has type 'Object'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignabilityInInheritance.ts(109,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'E', but here has type 'Object'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignabilityInInheritance.ts (2 errors) ====
// enum is only a subtype of number, no types are subtypes of enum, all of these except the first are errors
enum E { A }
interface I0 {
[x: string]: E;
foo: E; // identical and subtype, ok
}
declare function foo(x: E): E;
declare function foo(x: number): number;
declare function foo(x: any): any;
var r = foo(E.A); // E
var r2 = foo(1); // number
var r3 = foo(<any>null); // any
declare function foo2(x: string): string;
declare function foo2(x: E): E;
var r4 = foo2(E.A);
declare function foo3(x: boolean): boolean;
declare function foo3(x: E): E;
var r4 = foo3(E.A);
declare function foo4(x: Date): Date;
declare function foo4(x: E): E;
var r4 = foo4(E.A);
declare function foo5(x: RegExp): RegExp;
declare function foo5(x: E): E;
var r4 = foo5(E.A);
declare function foo6(x: { bar: number }): { bar: number };
declare function foo6(x: E): E;
var r4 = foo6(E.A);
declare function foo7(x: number[]): number[];
declare function foo7(x: E): E;
var r4 = foo7(E.A);
interface I8 { foo: string; }
declare function foo8(x: I8): I8;
declare function foo8(x: E): E;
var r4 = foo8(E.A);
class A { foo: number; }
declare function foo9(x: A): A;
declare function foo9(x: E): E;
var r4 = foo9(E.A);
class A2<T> { foo: T; }
declare function foo10(x: A2<number>): A2<number>;
declare function foo10(x: E): E;
var r4 = foo10(E.A);
declare function foo11(x: (x) => number): (x) => number;
declare function foo11(x: E): E;
var r4 = foo11(E.A);
declare function foo12(x: <T>(x: T) => T): <T>(x: T) => T;
declare function foo12(x: E): E;
var r4 = foo12(E.A);
enum E2 { A }
declare function foo13(x: E2): E2;
declare function foo13(x: E): E;
var r4 = foo13(E.A);
function f() { }
module f {
export var bar = 1;
}
declare function foo14(x: typeof f): typeof f;
declare function foo14(x: E): E;
var r4 = foo14(E.A);
class CC { baz: string }
module CC {
export var bar = 1;
}
declare function foo15(x: CC): CC;
declare function foo15(x: E): E;
var r4 = foo15(E.A);
declare function foo16(x: Object): Object;
declare function foo16(x: E): E;
var r4 = foo16(E.A);
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'E', but here has type 'Object'.
!!! related TS6203 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignabilityInInheritance.ts:22:5: 'r4' was also declared here.
declare function foo17(x: {}): {};
declare function foo17(x: E): E;
var r4 = foo16(E.A);
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'E', but here has type 'Object'.
!!! related TS6203 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignabilityInInheritance.ts:22:5: 'r4' was also declared here.