Files
tsgo/testdata/baselines/reference/submodule/conformance/infiniteExpansionThroughInstantiation.errors.txt

43 lines
1.8 KiB
Plaintext

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'.
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'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'List<T>'.
==== 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;
}
declare var list: List<string>;
declare 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'.
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'List<T>'.
}