33 lines
No EOL
1.1 KiB
Text
33 lines
No EOL
1.1 KiB
Text
==== 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;
|
|
~~~~
|
|
!!! 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'.
|
|
|
|
function other<T>(x: T) {
|
|
var list: List<T>;
|
|
var ownerList: OwnerList<T>;
|
|
list = ownerList;
|
|
~~~~
|
|
!!! 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'.
|
|
|
|
}
|
|
|