From f436b151aa379a4180a5dfbe359846860586195e Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Sat, 24 Dec 2022 17:37:29 +0000 Subject: [PATCH] Added a type that unwraps promises --- src/utils/types/promise-type.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/utils/types/promise-type.ts diff --git a/src/utils/types/promise-type.ts b/src/utils/types/promise-type.ts new file mode 100644 index 0000000..233d7c0 --- /dev/null +++ b/src/utils/types/promise-type.ts @@ -0,0 +1,6 @@ +/** + * Obtains the underlying type of a {@link Promise}. + * + * @template T - A `Promise` type to extract the underlying type from. + */ +export type PromiseType> = T extends Promise ? U : never;