2022-08-30

Is there a way to constrain a generic type parameter to generic types?

Is there a way to constrain a generic type parameter to generic types?

//I can constrain a parameter to only object types like this
type GenericType<T extends object> = keyof T ...
//How can I do that for generic types?
type GenericModifier<T extends /* Generic<T> */> = T<...>
//I want to do something like this:
type Distribute<target, type> = type extends infer A ? target<A> : never;

Is that possible?



No comments:

Post a Comment