Here is the code
class A {
x = 0;
y = 0;
visible = false;
render() {
}
}
type RemoveProperties = {
readonly [P in keyof T
You can now use as clauses in mapped types to filter out properties in one go:
type Methods = { [P in keyof T as T[P] extends Function ? P : never]: T[P] };
type A_Methods = Methods; // { render: () => void; }
When the type specified in an
asclause resolves tonever, no property is generated for that key. Thus, anasclause can be used as a filter[.]
Further info: Announcing TypeScript 4.1 Beta
Playground