I have a function A that will return function B. The parameter of function B is object C, which has a property named D with a type of T.
T's value is determined when function B is fetched; this means T can be set when calling function A or using alternative methods.
How should this be defined in TypeScript? Thank you very much.
I've attempted the following approach which does work. However, it's not exactly what I'm aiming for:
interface C<T> {
d: T;
e: number;
}
interface B<T> {
(param: C<T>): void;
}
interface A<T> {
(): B<T>;
}
const a: A<number> = () => ({d, e}) => {
console.log(d, e)
};
What I'm looking for might resemble something like:
const a: A = () => ({d, e}) => {
console.log(d, e)
};
const b1 = a<number>();
const b2 = a<string>();
I'm unsure about how to achieve this.