Looking at this function I've created
function computedLastOf<T>(cb: () => T[]) : Readonly<Ref<T | undefined>> {
return computed(() => {
const collection = cb();
return collection[collection.length - 1];
});
}
This function acts as a macro that produces a reactive value for a generic type T collection.
The issue here is the explicit <T>
which requires the user to specify the type. It would be great if this could be inferred automatically. The output of this function will always be an element from the collection returned by the callback.
Is there a way to achieve automatic type inference like this?
Appreciate any guidance!