forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 4
/
varianceRepeatedlyPropegatesWithUnreliableFlag.types
51 lines (41 loc) · 1.32 KB
/
varianceRepeatedlyPropegatesWithUnreliableFlag.types
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
=== tests/cases/compiler/varianceRepeatedlyPropegatesWithUnreliableFlag.ts ===
type A = { a: number };
>A : A
>a : number
type B = { b: number };
>B : B
>b : number
type X<T> = ({ [K in keyof T]: T[K] } & Record<string, void>)[keyof T];
>X : ({ [K in keyof T]: T[K]; } & Record<string, void>)[keyof T]
type P1<T> = { data: X<T> };
>P1 : P1<T>
>data : ({ [K in keyof T]: T[K]; } & Record<string, void>)[keyof T]
type P2<T> = { data: X<T> };
>P2 : P2<T>
>data : ({ [K in keyof T]: T[K]; } & Record<string, void>)[keyof T]
interface I<T> {
fn<K extends keyof T>(p1: P1<Pick<T, K>>, p2: P2<Pick<T, K>>): void;
>fn : <K extends keyof T>(p1: P1<Pick<T, K>>, p2: P2<Pick<T, K>>) => void
>p1 : P1<Pick<T, K>>
>p2 : P2<Pick<T, K>>
}
const i: I<A & B> = null as any;
>i : I<A & B>
>null as any : any
>null : null
const p2: P2<A> = null as any;
>p2 : P2<A>
>null as any : any
>null : null
// Commenting out the below line will remove the error on the `const _i: I<A> = i;`
i.fn(null as any, p2);
>i.fn(null as any, p2) : void
>i.fn : <K extends "a" | "b">(p1: P1<Pick<A & B, K>>, p2: P2<Pick<A & B, K>>) => void
>i : I<A & B>
>fn : <K extends "a" | "b">(p1: P1<Pick<A & B, K>>, p2: P2<Pick<A & B, K>>) => void
>null as any : any
>null : null
>p2 : P2<A>
const _i: I<A> = i;
>_i : I<A>
>i : I<A & B>