I have this function which I want to make more type safe. The first argument is a callback and rest of the arguments which will be passed to the function (Maybe pre processed or stored passed later, but to for now lets assumed it immediately called).
//The callback type
type component<T extends Attr = Attr, U extends node = node, R extends node = node>= ((attr: T, ...content: U[]) => R)
export function c(name: component, attr: Attr /*The first param of name*/, ...content: node[]/* Remaining Parameters name*/): node /*Return Type of name*/ {
return name(attr, content)
}
Google gives me an option using ReturnType<T> but that only works when the return type is any.
Any solutions here?