TypeScript/tests/baselines/reference/checkOrderDependenceGenericAssignability.errors.txt
2021-08-29 16:19:05 -07:00

65 lines
2.2 KiB
Plaintext

tests/cases/compiler/checkOrderDependenceGenericAssignability.ts(24,1): error TS2322: Type 'Parent1<unknown>' is not assignable to type 'Parent1<string>'.
Type 'unknown' is not assignable to type 'string'.
tests/cases/compiler/checkOrderDependenceGenericAssignability.ts(51,1): error TS2322: Type 'Parent2<unknown>' is not assignable to type 'Parent2<string>'.
Type 'unknown' is not assignable to type 'string'.
==== tests/cases/compiler/checkOrderDependenceGenericAssignability.ts (2 errors) ====
// Repro from #44572 with interface types
interface Parent1<A> {
child: Child1<A>;
parent: Parent1<A>;
}
interface Child1<A, B = unknown> extends Parent1<A> {
readonly a: A;
// This field isn't necessary to the repro, but the
// type parameter is, so including it
readonly b: B;
}
function fn1<A>(inp: Child1<A>) {
// This assignability check defeats the later one
const a: Child1<unknown> = inp;
}
declare let pu1: Parent1<unknown>;
declare let ps1: Parent1<string>;
pu1 = ps1; // Ok
ps1 = pu1; // Error expected
~~~
!!! error TS2322: Type 'Parent1<unknown>' is not assignable to type 'Parent1<string>'.
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
// Repro from #44572 with aliased object types
type Parent2<A> = {
child: Child2<A>;
parent: Parent2<A>;
}
type Child2<A, B = unknown> = {
child: Child2<A>;
parent: Parent2<A>;
readonly a: A;
// This field isn't necessary to the repro, but the
// type parameter is, so including it
readonly b: B;
}
function fn2<A>(inp: Child2<A>) {
// This assignability check defeats the later one
const a: Child2<unknown> = inp;
}
declare let pu2: Parent2<unknown>;
declare let ps2: Parent2<string>;
pu2 = ps2; // Ok
ps2 = pu2; // Error expected
~~~
!!! error TS2322: Type 'Parent2<unknown>' is not assignable to type 'Parent2<string>'.
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.