From 2c2bcb4de70492ae5d67c40782ff0816b6196287 Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Sun, 25 Dec 2022 12:49:05 +0000 Subject: [PATCH] Added a type that unwraps constructor return type --- src/utils/types/constructor-return-type.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/utils/types/constructor-return-type.ts diff --git a/src/utils/types/constructor-return-type.ts b/src/utils/types/constructor-return-type.ts new file mode 100644 index 0000000..0337288 --- /dev/null +++ b/src/utils/types/constructor-return-type.ts @@ -0,0 +1,6 @@ +/** + * Obtains the return type of a constructor function. + * + * @template T - The constructor function. + */ +export type ConstructorReturnType unknown> = T extends new () => infer R ? R : never;