Browse Source

feat: add Options utility type

pull/6537/head
Arman Ozak 6 years ago
parent
commit
929f03ff7c
  1. 14
      npm/ng-packs/packages/schematics/src/models/util.ts

14
npm/ng-packs/packages/schematics/src/models/util.ts

@ -1,2 +1,16 @@
// Omissible (given keys will become optional)
export type Omissible<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
// ExcludeKeys (keys will be excluded based on their type)
type ExcludeKeys<Type, Excluded> = Exclude<
{
[Key in keyof Type]: Type[Key] extends Excluded ? never : Key;
}[keyof Type],
never
>;
// tslint:disable-next-line: ban-types
type ExcludeMethods<Type> = Pick<Type, ExcludeKeys<Type, Function>>;
// Options (methods will be omitted, given keys will become optional)
export type Options<T, K extends keyof ExcludeMethods<T>> = Omissible<ExcludeMethods<T>, K>;

Loading…
Cancel
Save