Imagine a scenario where you have a class called Base
. In this class, the print
method requires a parameter that merges IBaseContext
with a generic type T
.
interface IBaseContext {
a: number
}
class Base<T> {
public print(context: IBaseContext & T) {
}
}
We are now asked to utilize the Test
class to inherit from the Base
class.
interface IMoreContext {
b: string
}
class Test extends Base<IMoreContext> {
public print(context) {
}
}
The expected overridden print
method should infer the parameter as IBaseContext & IMoreContext
, but instead it is being inferred as any
.
I have attempted various fixes such as converting the class Base
into an abstract class, replacing the interfaces with types, or exploring solutions like DeepMergeTwoTypes, all without success.
If anyone knows how to resolve this issue and make the correct inference, your input would be greatly appreciated. Thank you.