I am looking for a utility type that will allow me to extract the generic parameter of a set, but I only have available the typed set, so basically
type Bar = Set<Foo>;
type Baz = SomethingMagic<Bar>; // Baz should equal Foo
>Solution :
You can do that with the infer keyword:
type SomethingMagic<T> = T extends Set<infer U> ? U : never