Encountering a challenge with TypeScript where I need to selectively add properties to a generic interface depending on the type parameter. Let me explain further with an example:
Consider two interfaces, A and G<T>:
interface A {
IA: string;
}
interface G<T> {
IG: string;
Parent: T;
}
My goal is to include additional properties in G<T> only when it's used with type A. For instance, when using G<A>, I want to introduce properties like prop1, but not when using G<B> (with B being another type). It should look something like this:
inteface G<T> extends A {
prop1: string;
}
In need of a solution or different approach to achieve this conditional property addition based on the type parameter. Open to ideas and recommendations. Thank you!