Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

require-at-least-one.d.ts 848B

123456789101112131415161718192021222324252627282930313233
  1. import {Except} from './except';
  2. /**
  3. Create a type that requires at least one of the given keys. The remaining keys are kept as is.
  4. @example
  5. ```
  6. import {RequireAtLeastOne} from 'type-fest';
  7. type Responder = {
  8. text?: () => string;
  9. json?: () => string;
  10. secure?: boolean;
  11. };
  12. const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
  13. json: () => '{"message": "ok"}',
  14. secure: true
  15. };
  16. ```
  17. */
  18. export type RequireAtLeastOne<
  19. ObjectType,
  20. KeysType extends keyof ObjectType = keyof ObjectType
  21. > = {
  22. // For each `Key` in `KeysType` make a mapped type:
  23. [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & // 1. Make `Key`'s type required
  24. // 2. Make all other keys in `KeysType` optional
  25. Partial<Pick<ObjectType, Exclude<KeysType, Key>>>;
  26. }[KeysType] &
  27. // 3. Add the remaining keys not in `KeysType`
  28. Except<ObjectType, KeysType>;