Class B extends a generic class A, and I am trying to infer the generic type of A that B is extending. The code snippet below demonstrates this.
In earlier versions of TypeScript, this worked correctly for me. However, in my current project using version 3.2.4 (I also tried the latest 3.4.5), the inferred type now returns {}
instead of string
.
Any thoughts on what might be causing this issue? Could there have been changes that affect this behavior?
class A<T> {
}
class B extends A<string> {
}
type GenericOf<T> = T extends A<infer X> ? X : never;
type t = GenericOf<B>; // currently results in {}, when expected string