-
-
Notifications
You must be signed in to change notification settings - Fork 679
Proposal: SubType #22
Copy link
Copy link
Closed
Description
type SubType<Base, Condition> = Pick<
Base,
{
[Key in keyof Base]: Base[Key] extends Condition ? Key : never
}[keyof Base]
>;Examples:
var object = {
a: 1,
b: true,
c: () => null,
d: () => null,
};
type JustMethods = SubType<typeof object, (...args: unknown[]) => unknown>;
// { c: () => null, d: () => null }JustMethods from #4 can be realized via SubType. But, as I understand, JustProps can't. Maybe it will be possible after microsoft/TypeScript#29317
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels