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.

value-of.d.ts 829B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. Create a union of the given object's values, and optionally specify which keys to get the values from.
  3. Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
  4. @example
  5. ```
  6. // data.json
  7. {
  8. 'foo': 1,
  9. 'bar': 2,
  10. 'biz': 3
  11. }
  12. // main.ts
  13. import {ValueOf} from 'type-fest';
  14. import data = require('./data.json');
  15. export function getData(name: string): ValueOf<typeof data> {
  16. return data[name];
  17. }
  18. export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
  19. return data[name];
  20. }
  21. // file.ts
  22. import {getData, onlyBar} from './main';
  23. getData('foo');
  24. //=> 1
  25. onlyBar('foo');
  26. //=> TypeError ...
  27. onlyBar('bar');
  28. //=> 2
  29. ```
  30. */
  31. export type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];