Consider this code:
class A<T> { t?: T; }
interface B {}
class C implements A<B> {}
function f<T1 extends A<T2>, T2>(a: T1): T2 | undefined { return a.t; }
const result = f(new C());
const result2 = f(new A<B>());
It turns out that the type of result or even result2 will be unknown, while it can be inferred from the context, as C is implementing A<B> (so it can be inferred as B).
Why typescript does not do that? Is it a missing feature, a non-sound inference or is there another way to achieve desired behavior?