File: typeParameterAsTypeParameterConstraint2.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 3,459 bytes parent folder | download | duplicates (2)
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
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(6,8): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(7,8): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(13,17): error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,9): error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'.
  Types of property 'length' are incompatible.
    Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(17,9): error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'.
  Types of property 'length' are incompatible.
    Type '{}' is not assignable to type 'number'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(18,10): error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'.
  Types of property 'length' are incompatible.
    Type 'number' is not assignable to type 'any[]'.


==== tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts (6 errors) ====
    // using a type parameter as a constraint for a type parameter is invalid
    // these should be errors unless otherwise noted
    
    function foo<T, U extends T>(x: T, y: U): U { return y; } // this is now an error
    
    foo(1, '');
           ~~
!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
    foo(1, {});
           ~~
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
    
    interface NumberVariant extends Number {
        x: number;
    }
    var n: NumberVariant;
    var r3 = foo(1, n);
                    ~
!!! error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'.
    
    function foo2<T, U extends { length: T }>(x: T, y: U) { return y; } // this is now an error
    foo2(1, { length: '' });
            ~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'.
!!! error TS2345:   Types of property 'length' are incompatible.
!!! error TS2345:     Type 'string' is not assignable to type 'number'.
    foo2(1, { length: {} });
            ~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ length: {}; }' is not assignable to parameter of type '{ length: number; }'.
!!! error TS2345:   Types of property 'length' are incompatible.
!!! error TS2345:     Type '{}' is not assignable to type 'number'.
    foo2([], ['']);
             ~~~~
!!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type '{ length: any[]; }'.
!!! error TS2345:   Types of property 'length' are incompatible.
!!! error TS2345:     Type 'number' is not assignable to type 'any[]'.