I have an object containing one or more PreparedStatement. I need to generalize the type definition for such object. Is it possible to represent that?
type PreparedQuery<Input, Result> = {
input: Input;
result: Result;
};
type Query = {
[Key in string]: PreparedQuery<Input, Result>;
};
Each value of the Query type of object would be PreparedQuery but with different Input and/or Result. The main goal is to write a function that will take a this object and return a new object that will have the type (Query -> GeneratedQueries):
type GeneratedQueries = {
[Key in string]: <Input, Result>(input: Input) => Promise<Result>;
}
So, how do define/represent this Query type than can have any type of for its generic arguments?