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.

promise-value.d.ts 1.0KB

123456789101112131415161718192021222324252627
  1. /**
  2. Returns the type that is wrapped inside a `Promise` type.
  3. If the type is a nested Promise, it is unwrapped recursively until a non-Promise type is obtained.
  4. If the type is not a `Promise`, the type itself is returned.
  5. @example
  6. ```
  7. import {PromiseValue} from 'type-fest';
  8. type AsyncData = Promise<string>;
  9. let asyncData: PromiseValue<AsyncData> = Promise.resolve('ABC');
  10. type Data = PromiseValue<AsyncData>;
  11. let data: Data = await asyncData;
  12. // Here's an example that shows how this type reacts to non-Promise types.
  13. type SyncData = PromiseValue<string>;
  14. let syncData: SyncData = getSyncData();
  15. // Here's an example that shows how this type reacts to recursive Promise types.
  16. type RecursiveAsyncData = Promise<Promise<string> >;
  17. let recursiveAsyncData: PromiseValue<RecursiveAsyncData> = Promise.resolve(Promise.resolve('ABC'));
  18. ```
  19. */
  20. export type PromiseValue<PromiseType, Otherwise = PromiseType> = PromiseType extends Promise<infer Value>
  21. ? { 0: PromiseValue<Value>; 1: Value }[PromiseType extends Promise<unknown> ? 0 : 1]
  22. : Otherwise;