TypeScript/tests/baselines/reference/promisesWithConstraints.types

85 lines
1.4 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/compiler/promisesWithConstraints.ts ===
interface Promise<T> {
>Promise : Promise<T>
>T : T
2014-08-15 23:33:16 +02:00
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
2014-08-15 23:33:16 +02:00
}
interface CPromise<T extends { x: any; }> {
>CPromise : CPromise<T>
>T : T
>x : any
2014-08-15 23:33:16 +02:00
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
2014-08-15 23:33:16 +02:00
}
interface Foo { x; }
>Foo : Foo
>x : any
2014-08-15 23:33:16 +02:00
interface Bar { x; y; }
>Bar : Bar
>x : any
>y : any
2014-08-15 23:33:16 +02:00
var a: Promise<Foo>;
>a : Promise<Foo>
>Promise : Promise<T>
>Foo : Foo
2014-08-15 23:33:16 +02:00
var b: Promise<Bar>;
>b : Promise<Bar>
>Promise : Promise<T>
>Bar : Bar
2014-08-15 23:33:16 +02:00
a = b; // ok
>a = b : Promise<Bar>
>a : Promise<Foo>
>b : Promise<Bar>
2014-08-15 23:33:16 +02:00
b = a; // ok
>b = a : Promise<Foo>
>b : Promise<Bar>
>a : Promise<Foo>
2014-08-15 23:33:16 +02:00
var a2: CPromise<Foo>;
>a2 : CPromise<Foo>
>CPromise : CPromise<T>
>Foo : Foo
2014-08-15 23:33:16 +02:00
var b2: CPromise<Bar>;
>b2 : CPromise<Bar>
>CPromise : CPromise<T>
>Bar : Bar
2014-08-15 23:33:16 +02:00
a2 = b2; // ok
>a2 = b2 : CPromise<Bar>
>a2 : CPromise<Foo>
>b2 : CPromise<Bar>
2014-08-15 23:33:16 +02:00
b2 = a2; // was error
>b2 = a2 : CPromise<Foo>
>b2 : CPromise<Bar>
>a2 : CPromise<Foo>
2014-08-15 23:33:16 +02:00