Given a utility ExtractKeysOfType
that allows to retrieve only key of a type/interface that match a target and the Pick
type i can easily extract function from a given type/interface.
What I want to accomplish is to extract only the async function (and not all signatures) from the base type.
Any clue on how to achieve that ?
type ExtractKeysOfType<T, Target> = {
[K in keyof T]: T[K] extends Target ? K : never
}[keyof T]
type Type = {
prop: boolean
fn (): boolean
fn (): Promise<boolean>
}
type OnlyFunc = Pick<
Type,
ExtractKeysOfType<Type, (...as: any) => any>
> // {fn (): {boolean; Promise<boolean>}
type OnlyAsync = ??? // Someway to build type such as OnlyAsync: {fn (): Promise<boolean>}