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.

set-required.d.ts 1.0KB

12345678910111213141516171819202122232425262728293031323334
  1. import {Except} from './except';
  2. /**
  3. Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
  4. Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.
  5. @example
  6. ```
  7. import {SetRequired} from 'type-fest';
  8. type Foo = {
  9. a?: number;
  10. b: string;
  11. c?: boolean;
  12. }
  13. type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
  14. // type SomeRequired = {
  15. // a?: number;
  16. // b: string; // Was already required and still is.
  17. // c: boolean; // Is now required.
  18. // }
  19. ```
  20. */
  21. export type SetRequired<BaseType, Keys extends keyof BaseType = keyof BaseType> =
  22. // Pick just the keys that are not required from the base type.
  23. Except<BaseType, Keys> &
  24. // Pick the keys that should be required from the base type and make them required.
  25. Required<Pick<BaseType, Keys>> extends
  26. // If `InferredType` extends the previous, then for each key, use the inferred type key.
  27. infer InferredType
  28. ? {[KeyType in keyof InferredType]: InferredType[KeyType]}
  29. : never;