File: varianceRepeatedlyPropegatesWithUnreliableFlag.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (51 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (3)
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: number; }
>a : number

type B = { b: number };
>B : { b: number; }
>b : number

type X<T> = ({ [K in keyof T]: T[K] } & Record<string, void>)[keyof T];
>X : X<T>

type P1<T> = { data: X<T> };
>P1 : P1<T>
>data : X<T>

type P2<T> = { data: X<T> };
>P2 : P2<T>
>data : X<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>