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
|
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,59): error TS2345: Argument of type '(c: C) => B' is not assignable to parameter of type '(x: C) => C'.
Type 'B' is not assignable to type 'C'.
Property 'z' is missing in type 'B'.
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (1 errors) ====
class Chain<T extends A> {
constructor(public value: T) { }
then<S extends T>(cb: (x: T) => S): Chain<S> {
return null;
}
}
class A {
x;
}
class B extends A {
y;
}
class C extends B {
z;
}
// Ok to go down the chain, but error to try to climb back up
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
~~~~~~~~~~
!!! error TS2345: Argument of type '(c: C) => B' is not assignable to parameter of type '(x: C) => C'.
!!! error TS2345: Type 'B' is not assignable to type 'C'.
!!! error TS2345: Property 'z' is missing in type 'B'.
|