You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tests/cases/compiler/emptyClassSomehowNeverChecksConditionals.ts(5,7): error TS2322: Type 'EqualsTest<string>' is not assignable to type 'EqualsTest<number>'.
2
+
Type 'any extends string ? 1 : 0' is not assignable to type 'any extends number ? 1 : 0'.
3
+
Type '0 | 1' is not assignable to type 'any extends number ? 1 : 0'.
4
+
Type '0' is not assignable to type 'any extends number ? 1 : 0'.
5
+
tests/cases/compiler/emptyClassSomehowNeverChecksConditionals.ts(6,7): error TS2322: Type 'EqualsTest1<string>' is not assignable to type 'EqualsTest<number>'.
6
+
Type 'A extends string ? 1 : 0' is not assignable to type 'A extends number ? 1 : 0'.
7
+
Type '0 | 1' is not assignable to type 'A extends number ? 1 : 0'.
8
+
Type '0' is not assignable to type 'A extends number ? 1 : 0'.
9
+
tests/cases/compiler/emptyClassSomehowNeverChecksConditionals.ts(12,27): error TS2344: Type 'this' does not satisfy the constraint 'Model<typeof Model>'.
10
+
Type 'Model<MClass>' is not assignable to type 'Model<typeof Model>'.
11
+
Types of property 'set' are incompatible.
12
+
Type '<K>(value: K extends MClass ? number : string) => void' is not assignable to type '<K>(value: K extends typeof Model ? number : string) => void'.
13
+
Types of parameters 'value' and 'value' are incompatible.
14
+
Type 'K extends typeof Model ? number : string' is not assignable to type 'K extends MClass ? number : string'.
15
+
Type 'string | number' is not assignable to type 'K extends MClass ? number : string'.
16
+
Type 'string' is not assignable to type 'K extends MClass ? number : string'.
17
+
tests/cases/compiler/emptyClassSomehowNeverChecksConditionals.ts(20,28): error TS2344: Type 'this' does not satisfy the constraint 'ModelSub'.
18
+
Type 'Model2<MClass>' is not assignable to type 'Model2<typeof ModelSub>'.
19
+
Types of property 'set' are incompatible.
20
+
Type '<K>(value: K extends MClass ? number : string) => void' is not assignable to type '<K>(value: K extends typeof ModelSub ? number : string) => void'.
21
+
Types of parameters 'value' and 'value' are incompatible.
22
+
Type 'K extends typeof ModelSub ? number : string' is not assignable to type 'K extends MClass ? number : string'.
23
+
Type 'string | number' is not assignable to type 'K extends MClass ? number : string'.
24
+
Type 'string' is not assignable to type 'K extends MClass ? number : string'.
// quick distillation of conditionals which were previously erased by signature relating
29
+
type EqualsTest<T> = <A>() => A extends T ? 1 : 0;
30
+
type EqualsTest1<T> = <A>() => A extends T ? 1 : 0;
31
+
32
+
const x: EqualsTest<number> = undefined as any as EqualsTest<string>; // should error, obviously wrong
33
+
~
34
+
!!! error TS2322: Type 'EqualsTest<string>' is not assignable to type 'EqualsTest<number>'.
35
+
!!! error TS2322: Type 'any extends string ? 1 : 0' is not assignable to type 'any extends number ? 1 : 0'.
36
+
!!! error TS2322: Type '0 | 1' is not assignable to type 'any extends number ? 1 : 0'.
37
+
!!! error TS2322: Type '0' is not assignable to type 'any extends number ? 1 : 0'.
38
+
const y: EqualsTest<number> = undefined as any as EqualsTest1<string>; // same as the above, but seperate type aliases
39
+
~
40
+
!!! error TS2322: Type 'EqualsTest1<string>' is not assignable to type 'EqualsTest<number>'.
41
+
!!! error TS2322: Type 'A extends string ? 1 : 0' is not assignable to type 'A extends number ? 1 : 0'.
42
+
!!! error TS2322: Type '0 | 1' is not assignable to type 'A extends number ? 1 : 0'.
43
+
!!! error TS2322: Type '0' is not assignable to type 'A extends number ? 1 : 0'.
44
+
45
+
// Slightly extended example using class inheritance
46
+
type ModelId<M extends Model> = M; // just validates the input matches the `Model` type to issue an error
47
+
export declare class Model<MClass extends typeof Model = typeof Model> {
48
+
class: MClass;
49
+
readonly ref: ModelId<this>;
50
+
~~~~
51
+
!!! error TS2344: Type 'this' does not satisfy the constraint 'Model<typeof Model>'.
52
+
!!! error TS2344: Type 'Model<MClass>' is not assignable to type 'Model<typeof Model>'.
53
+
!!! error TS2344: Types of property 'set' are incompatible.
54
+
!!! error TS2344: Type '<K>(value: K extends MClass ? number : string) => void' is not assignable to type '<K>(value: K extends typeof Model ? number : string) => void'.
55
+
!!! error TS2344: Types of parameters 'value' and 'value' are incompatible.
56
+
!!! error TS2344: Type 'K extends typeof Model ? number : string' is not assignable to type 'K extends MClass ? number : string'.
57
+
!!! error TS2344: Type 'string | number' is not assignable to type 'K extends MClass ? number : string'.
58
+
!!! error TS2344: Type 'string' is not assignable to type 'K extends MClass ? number : string'.
59
+
set<K>(value: K extends MClass ? number : string): void;
60
+
}
61
+
62
+
// identical to the above, but with a no-op subclass
!!! error TS2344: Type 'this' does not satisfy the constraint 'ModelSub'.
69
+
!!! error TS2344: Type 'Model2<MClass>' is not assignable to type 'Model2<typeof ModelSub>'.
70
+
!!! error TS2344: Types of property 'set' are incompatible.
71
+
!!! error TS2344: Type '<K>(value: K extends MClass ? number : string) => void' is not assignable to type '<K>(value: K extends typeof ModelSub ? number : string) => void'.
72
+
!!! error TS2344: Types of parameters 'value' and 'value' are incompatible.
73
+
!!! error TS2344: Type 'K extends typeof ModelSub ? number : string' is not assignable to type 'K extends MClass ? number : string'.
74
+
!!! error TS2344: Type 'string | number' is not assignable to type 'K extends MClass ? number : string'.
75
+
!!! error TS2344: Type 'string' is not assignable to type 'K extends MClass ? number : string'.
76
+
set<K>(value: K extends MClass ? number : string): void;
0 commit comments