File: genericCallWithObjectTypeArgsAndInitializers.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (23 lines) | stat: -rw-r--r-- 1,659 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type '1' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(6,37): error TS2322: Type 'T' is not assignable to type 'U'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(8,56): error TS2322: Type 'U' is not assignable to type 'V'.
  Type 'T' is not assignable to type 'V'.


==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts (3 errors) ====
    // Generic typed parameters with initializers
    
    function foo<T>(x: T = null) { return x; } // ok
    function foo2<T>(x: T = undefined) { return x; } // ok
    function foo3<T extends Number>(x: T = 1) { } // error
                                    ~~~~~~~~
!!! error TS2322: Type '1' is not assignable to type 'T'.
    function foo4<T, U extends T>(x: T, y: U = x) { } // error
                                        ~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'U'.
    function foo5<T, U extends T>(x: U, y: T = x) { } // ok
    function foo6<T, U extends T, V extends U>(x: T, y: U, z: V = y) { } // error
                                                           ~~~~~~~~
!!! error TS2322: Type 'U' is not assignable to type 'V'.
!!! error TS2322:   Type 'T' is not assignable to type 'V'.
    function foo7<T, U extends T, V extends U>(x: V, y: U = x) { } // should be ok