While developing an interface for an options object, I am aiming to allow the user to specify a function with an explicit return type and a generic argument type. This can be achieved if a type has not been defined for the function beforehand. However, I am facing difficulty in implementing this for a function type that has already been defined.
For example, the following code snippet works without any issues:
interface Options {
// Other options...
converterFunction: <T>(rawData: T) => [];
}
But the following syntax, which seems logical, does not work as expected:
type ConverterFunction<T> = (rawData: T) => [];
interface Options {
// Other options...
converterFunction: <T>ConverterFunction<T>; // TypeScript is unhappy
}
Simply making the interface generic does not solve my problem, and I would prefer to use my pre-defined types instead of defining them again arbitrarily.