Let's say I have a TypeScript type that looks like this:
type Utilities = {
getFeatureFlag: (name: string) => string;
apiRequest: (endpoint: string) => Promise<object>;
getConfig: (name: string) => Promise<object>;
}
And from this type, I want generate a subtype where the only key/value pairs to keep are those where the values are functions that return promises. So the resulting type would be the following (same, but with getFeatureFlag
omitted):
type PromiseUtilities = {
apiRequest: (endpoint: string) => Promise<object>;
getConfig: (name: string) => Promise<object>;
}
Is it possible to do this with some set of TypeScript utilities or keywords?