File: promiseChaining1.errors.txt

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 (21 lines) | stat: -rw-r--r-- 1,416 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
tests/cases/compiler/promiseChaining1.ts(7,55): error TS2322: Type 'string' is not assignable to type 'Function'.
tests/cases/compiler/promiseChaining1.ts(7,84): error TS2322: Type 'number' is not assignable to type 'Function'.


==== tests/cases/compiler/promiseChaining1.ts (2 errors) ====
    // same example but with constraints on each type parameter
    class Chain2<T extends { length: number }> {
        constructor(public value: T) { }
        then<S extends Function>(cb: (x: T) => S): Chain2<S> {
            var result = cb(this.value);
            // should get a fresh type parameter which each then call
            var z = this.then(x => result)/*S*/.then(x => "abc")/*Function*/.then(x => x.length)/*number*/; // Should error on "abc" because it is not a Function
                                                          ~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'Function'.
!!! related TS6502 tests/cases/compiler/promiseChaining1.ts:4:34: The expected type comes from the return type of this signature.
                                                                                       ~~~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'Function'.
!!! related TS6502 tests/cases/compiler/promiseChaining1.ts:4:34: The expected type comes from the return type of this signature.
            return new Chain2(result);
        }
    }