File: genericCallWithObjectTypeArgs.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 (31 lines) | stat: -rw-r--r-- 1,045 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
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts(20,17): error TS2345: Argument of type 'X<D>' is not assignable to parameter of type 'X<C>'.
  Type 'D' is not assignable to type 'C'.
    Types have separate declarations of a private property 'x'.


==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs.ts (1 errors) ====
    class C {
        private x: string;
    }
    
    class D {
        private x: string;
    }
    
    class X<T> {
        x: T;
    }
    
    function foo<T>(t: X<T>, t2: X<T>) {
        var x: T;
        return x;
    }
    
    var c1 = new X<C>();
    var d1 = new X<D>();
    var r = foo(c1, d1); // error
                    ~~
!!! error TS2345: Argument of type 'X<D>' is not assignable to parameter of type 'X<C>'.
!!! error TS2345:   Type 'D' is not assignable to type 'C'.
!!! error TS2345:     Types have separate declarations of a private property 'x'.
    var r2 = foo(c1, c1); // ok