I am in need of extracting a type from an object literal that I am constructing by hand. I have the following:
const makeFunc: { key: string, val: (p: TParam) => TResult } = <TParam, TResult>(p: TParam) => doSomething(p);
const myObj = {
getSomething: makeFunc(a),
getSomethingElse: makeFunc(b)
}
Let's assume a
is of type A
and makeFunc(a) is of type AR
and similarly b
is of type B
and makeFunc(b) is of type BR
. Now I need a type that resembles something like this:
interface extractedType {
getSomething: (a: A) => AR,
getSomethingElse: (b: B) => BR
}
Is there a way to accomplish this? If so, could someone throw some light or point me in the right direction?