Let's say I have the interface Foo with a generic of T that extends Bar:
interface Foo<T extends Bar> {
a: ...,
b: ...,
c: ...,
}
And I want a new interface that uses a subset of Foo
interface MyType<U> {
a: Foo<U>['a'],
c: Foo<U>['c'],
}
Is there a way to peg the generic parameter of my new type MyType to the constrained generic parameter of Foo with a utility type or something? My IDE would let me know that MyType's generic type, U, needs to extend Bar but I'd like to know if there's a way that doesn't depend on correction raised by the IDE say, if the original type, Foo's, generic constraint changes.
This would work but, again, has to be corrected if the generic constraint changes:
interface MyType<U extends Bar> {
a: Foo<U>['a'],
c: Foo<U>['c'],
}