I'm struggling to figure out how to pass a generic type which requires a parameter to a function only to have the function provide the param. Below is a contrived example to illustrate what I'm trying to do.
interface SingleItem<T> {
body: T
}
interface MultiItem<T> {
body: T[]
}
function requestImages<BodyType> () {
...
return resp as BodyType<Image>;
}
requestImage<SingleItem>(); //<-- will throw because SingleItem requires a parameter
requestImage<MultiItem>();
I realize I could modify SingleItem and MutliItem to have a default for the type but I'm trying to learn the details of typescript, not necessarily circumvent this problem. Is there a way to pass around generics?