From 929f03ff7c775c40995bc8fd010ebe57790b633f Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Tue, 8 Dec 2020 17:26:06 +0300 Subject: [PATCH] feat: add Options utility type --- .../packages/schematics/src/models/util.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/npm/ng-packs/packages/schematics/src/models/util.ts b/npm/ng-packs/packages/schematics/src/models/util.ts index 5ff732ccfe..0588ed7d5b 100644 --- a/npm/ng-packs/packages/schematics/src/models/util.ts +++ b/npm/ng-packs/packages/schematics/src/models/util.ts @@ -1,2 +1,16 @@ // Omissible (given keys will become optional) export type Omissible = Partial> & Omit; + +// ExcludeKeys (keys will be excluded based on their type) +type ExcludeKeys = Exclude< + { + [Key in keyof Type]: Type[Key] extends Excluded ? never : Key; + }[keyof Type], + never +>; + +// tslint:disable-next-line: ban-types +type ExcludeMethods = Pick>; + +// Options (methods will be omitted, given keys will become optional) +export type Options> = Omissible, K>;