File: contravariantTypeAliasInference.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 (49 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download | duplicates (4)
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
=== tests/cases/compiler/contravariantTypeAliasInference.ts ===
type Func1<T> = (x: T) => void;
>Func1 : Func1<T>
>x : T

type Func2<T> = ((x: T) => void) | undefined;
>Func2 : Func2<T>
>x : T

declare let f1: Func1<string>;
>f1 : Func1<string>

declare let f2: Func1<"a">;
>f2 : Func1<"a">

declare function foo<T>(f1: Func1<T>, f2: Func1<T>): void;
>foo : <T>(f1: Func1<T>, f2: Func1<T>) => void
>f1 : Func1<T>
>f2 : Func1<T>

foo(f1, f2);
>foo(f1, f2) : void
>foo : <T>(f1: Func1<T>, f2: Func1<T>) => void
>f1 : Func1<string>
>f2 : Func1<"a">

declare let g1: Func2<string>;
>g1 : Func2<string>

declare let g2: Func2<"a">;
>g2 : Func2<"a">

declare function bar<T>(g1: Func2<T>, g2: Func2<T>): void;
>bar : <T>(g1: Func2<T>, g2: Func2<T>) => void
>g1 : Func2<T>
>g2 : Func2<T>

bar(f1, f2);
>bar(f1, f2) : void
>bar : <T>(g1: Func2<T>, g2: Func2<T>) => void
>f1 : Func1<string>
>f2 : Func1<"a">

bar(g1, g2);
>bar(g1, g2) : void
>bar : <T>(g1: Func2<T>, g2: Func2<T>) => void
>g1 : Func2<string>
>g2 : Func2<"a">