I currently have an exported abstract class that has one generic. However, I now require two generics. I do not want to modify all existing classes that are using this class. Therefore, I am looking to add an optional generic class that extends an interface.
Here is my current implementation:
export abstract class SharedShell<T extends IBase, T1 extends IBase> implements OnInit, OnDestroy {}
What would be the best approach to make T1 optional? I attempted the following:
export abstract class SharedShell<T extends IBase, T1 extends IBase | Undefined = Undefined> implements OnInit, OnDestroy {}
However, I encountered a type error:
'IBase' can be assigned to the constraint of type 'T1', but 'T1' could potentially be instantiated with a different subtype of constraint 'IBase'.
This is where I am facing a roadblock. How should I proceed to address this issue?