File: infiniteExpansionThroughInstantiation.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 (41 lines) | stat: -rw-r--r-- 1,801 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation.ts(16,1): error TS2322: Type 'OwnerList<string>' is not assignable to type 'List<string>'.
  Types of property 'data' are incompatible.
    Type 'List<string>' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation.ts(21,5): error TS2322: Type 'OwnerList<T>' is not assignable to type 'List<T>'.
  Types of property 'data' are incompatible.
    Type 'List<T>' is not assignable to type 'T'.


==== tests/cases/conformance/types/typeRelationships/recursiveTypes/infiniteExpansionThroughInstantiation.ts (2 errors) ====
    // instantiating a derived type can cause an infinitely expanding type reference to be generated
    
    interface List<T> {
        data: T;
        next: List<T>;
        owner: OwnerList<T>;
    }
    
    // will have an owner property that is an infinitely expanding type reference
    interface OwnerList<U> extends List<List<U>> {
        name: string;
    }
    
    var list: List<string>;
    var ownerList: OwnerList<string>;
    list = ownerList; 
    ~~~~
!!! error TS2322: Type 'OwnerList<string>' is not assignable to type 'List<string>'.
!!! error TS2322:   Types of property 'data' are incompatible.
!!! error TS2322:     Type 'List<string>' is not assignable to type 'string'.
    
    function other<T>(x: T) {
        var list: List<T>;
        var ownerList: OwnerList<T>;
        list = ownerList; 
        ~~~~
!!! error TS2322: Type 'OwnerList<T>' is not assignable to type 'List<T>'.
!!! error TS2322:   Types of property 'data' are incompatible.
!!! error TS2322:     Type 'List<T>' is not assignable to type 'T'.
    
    }