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
|
=== tests/cases/compiler/promisesWithConstraints.ts ===
interface Promise<T> {
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
>then : { <TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(cb: (x: T) => Promise<U>): Promise<U>; }
>cb : (x: T) => Promise<U>
>x : T
}
interface CPromise<T extends { x: any; }> {
>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>
>x : any
>cb : (x: T) => Promise<U>
>x : T
}
interface Foo { x; }
>x : any
interface Bar { x; y; }
>x : any
>y : any
var a: Promise<Foo>;
>a : Promise<Foo>
var b: Promise<Bar>;
>b : Promise<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>
var b2: CPromise<Bar>;
>b2 : CPromise<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>
|