TS 4.1
You can use as
clauses in mapped types to filter out properties in one go:
type Methods<T> = { [P in keyof T as T[P] extends Function ? P : never]: T[P] };
type A_Methods = Methods<A>; // { render: () => void; }
When the type specified in an
as
clause resolves tonever
, no property is generated for that key. Thus, anas
clause can be used as a filter [.]
Further info: Announcing TypeScript 4.1 – Key Remapping in Mapped Types