File: promisesWithConstraints.types

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (84 lines) | stat: -rw-r--r-- 1,464 bytes parent folder | download | duplicates (2)
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
=== tests/cases/compiler/promisesWithConstraints.ts ===
interface Promise<T> {
>Promise : Promise<T>
>T : T

    then<U>(cb: (x: T) => Promise<U>): Promise<U>;
>then : <U>(cb: (x: T) => Promise<U>) => Promise<U>
>U : U
>cb : (x: T) => Promise<U>
>x : T
>T : T
>Promise : Promise<T>
>U : U
>Promise : Promise<T>
>U : U
}

interface CPromise<T extends { x: any; }> {
>CPromise : CPromise<T>
>T : T
>x : any

    then<U extends { x: any; }>(cb: (x: T) => Promise<U>): Promise<U>;
>then : <U extends { x: any; }>(cb: (x: T) => Promise<U>) => Promise<U>
>U : U
>x : any
>cb : (x: T) => Promise<U>
>x : T
>T : T
>Promise : Promise<T>
>U : U
>Promise : Promise<T>
>U : U
}

interface Foo { x; }
>Foo : Foo
>x : any

interface Bar { x; y; }
>Bar : Bar
>x : any
>y : any

var a: Promise<Foo>;
>a : Promise<Foo>
>Promise : Promise<T>
>Foo : Foo

var b: Promise<Bar>;
>b : Promise<Bar>
>Promise : Promise<T>
>Bar : Bar

a = b; // ok
>a = b : Promise<Bar>
>a : Promise<Foo>
>b : Promise<Bar>

b = a; // ok
>b = a : Promise<Foo>
>b : Promise<Bar>
>a : Promise<Foo>

var a2: CPromise<Foo>;
>a2 : CPromise<Foo>
>CPromise : CPromise<T>
>Foo : Foo

var b2: CPromise<Bar>;
>b2 : CPromise<Bar>
>CPromise : CPromise<T>
>Bar : Bar

a2 = b2; // ok
>a2 = b2 : CPromise<Bar>
>a2 : CPromise<Foo>
>b2 : CPromise<Bar>

b2 = a2; // was error
>b2 = a2 : CPromise<Foo>
>b2 : CPromise<Bar>
>a2 : CPromise<Foo>