TypeScript/tests/baselines/reference/promisesWithConstraints.types
2015-04-15 16:44:20 -07:00

85 lines
1.4 KiB
Plaintext

=== 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>