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
|
=== tests/cases/compiler/promiseChaining2.ts ===
// same example but with constraints on each type parameter
class Chain2<T extends { length: number }> {
>Chain2 : Symbol(Chain2, Decl(promiseChaining2.ts, 0, 0))
>T : Symbol(T, Decl(promiseChaining2.ts, 1, 13))
>length : Symbol(length, Decl(promiseChaining2.ts, 1, 24))
constructor(public value: T) { }
>value : Symbol(Chain2.value, Decl(promiseChaining2.ts, 2, 16))
>T : Symbol(T, Decl(promiseChaining2.ts, 1, 13))
then<S extends Function>(cb: (x: T) => S): Chain2<S> {
>then : Symbol(Chain2.then, Decl(promiseChaining2.ts, 2, 36))
>S : Symbol(S, Decl(promiseChaining2.ts, 3, 9))
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>cb : Symbol(cb, Decl(promiseChaining2.ts, 3, 29))
>x : Symbol(x, Decl(promiseChaining2.ts, 3, 34))
>T : Symbol(T, Decl(promiseChaining2.ts, 1, 13))
>S : Symbol(S, Decl(promiseChaining2.ts, 3, 9))
>Chain2 : Symbol(Chain2, Decl(promiseChaining2.ts, 0, 0))
>S : Symbol(S, Decl(promiseChaining2.ts, 3, 9))
var result = cb(this.value);
>result : Symbol(result, Decl(promiseChaining2.ts, 4, 11))
>cb : Symbol(cb, Decl(promiseChaining2.ts, 3, 29))
>this.value : Symbol(Chain2.value, Decl(promiseChaining2.ts, 2, 16))
>this : Symbol(Chain2, Decl(promiseChaining2.ts, 0, 0))
>value : Symbol(Chain2.value, Decl(promiseChaining2.ts, 2, 16))
// should get a fresh type parameter which each then call
var z = this.then(x => result).then(x => "abc").then(x => x.length);
>z : Symbol(z, Decl(promiseChaining2.ts, 6, 11))
>this.then(x => result).then : Symbol(Chain2.then, Decl(promiseChaining2.ts, 2, 36))
>this.then : Symbol(Chain2.then, Decl(promiseChaining2.ts, 2, 36))
>this : Symbol(Chain2, Decl(promiseChaining2.ts, 0, 0))
>then : Symbol(Chain2.then, Decl(promiseChaining2.ts, 2, 36))
>x : Symbol(x, Decl(promiseChaining2.ts, 6, 26))
>result : Symbol(result, Decl(promiseChaining2.ts, 4, 11))
>then : Symbol(Chain2.then, Decl(promiseChaining2.ts, 2, 36))
>x : Symbol(x, Decl(promiseChaining2.ts, 6, 44))
>x : Symbol(x, Decl(promiseChaining2.ts, 6, 61))
>x : Symbol(x, Decl(promiseChaining2.ts, 6, 61))
return new Chain2(result);
>Chain2 : Symbol(Chain2, Decl(promiseChaining2.ts, 0, 0))
>result : Symbol(result, Decl(promiseChaining2.ts, 4, 11))
}
}
|