File: promiseChaining.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (53 lines) | stat: -rw-r--r-- 1,474 bytes parent folder | download | duplicates (5)
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
=== tests/cases/compiler/promiseChaining.ts ===
class Chain<T> {
>Chain : Chain<T>

    constructor(public value: T) { }
>value : T

    then<S>(cb: (x: T) => S): Chain<S> {
>then : <S>(cb: (x: T) => S) => Chain<S>
>cb : (x: T) => S
>x : T

        var result = cb(this.value);
>result : S
>cb(this.value) : S
>cb : (x: T) => S
>this.value : T
>this : this
>value : T

        // should get a fresh type parameter which each then call
        var z = this.then(x => result)/*S*/.then(x => "abc")/*string*/.then(x => x.length)/*number*/; // No error
>z : Chain<number>
>this.then(x => result)/*S*/.then(x => "abc")/*string*/.then(x => x.length) : Chain<number>
>this.then(x => result)/*S*/.then(x => "abc")/*string*/.then : <S>(cb: (x: string) => S) => Chain<S>
>this.then(x => result)/*S*/.then(x => "abc") : Chain<string>
>this.then(x => result)/*S*/.then : <S>(cb: (x: S) => S) => Chain<S>
>this.then(x => result) : Chain<S>
>this.then : <S>(cb: (x: T) => S) => Chain<S>
>this : this
>then : <S>(cb: (x: T) => S) => Chain<S>
>x => result : (x: T) => S
>x : T
>result : S
>then : <S>(cb: (x: S) => S) => Chain<S>
>x => "abc" : (x: S) => string
>x : S
>"abc" : "abc"
>then : <S>(cb: (x: string) => S) => Chain<S>
>x => x.length : (x: string) => number
>x : string
>x.length : number
>x : string
>length : number

        return new Chain(result);
>new Chain(result) : Chain<S>
>Chain : typeof Chain
>result : S
    }
}