TypeScript/tests/cases/compiler/promisesWithConstraints.ts
2014-07-12 17:30:19 -07:00

21 lines
413 B
TypeScript

interface Promise<T> {
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
}
interface CPromise<T extends { x: any; }> {
then<U extends { x: any; }>(cb: (x: T) => Promise<U>): Promise<U>;
}
interface Foo { x; }
interface Bar { x; y; }
var a: Promise<Foo>;
var b: Promise<Bar>;
a = b; // ok
b = a; // ok
var a2: CPromise<Foo>;
var b2: CPromise<Bar>;
a2 = b2; // ok
b2 = a2; // was error