aboutsummaryrefslogtreecommitdiff
path: root/src/utils/types.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/types.ts')
-rw-r--r--src/utils/types.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/types.ts b/src/utils/types.ts
new file mode 100644
index 00000000..705d02d1
--- /dev/null
+++ b/src/utils/types.ts
@@ -0,0 +1,17 @@
+/**
+ * Type that represents a single method/function name of the given type.
+ */
+export type MethodOf<
+ ObjectType,
+ Signature extends (...args) => unknown = (...args) => unknown
+> = {
+ [Key in keyof ObjectType]: ObjectType[Key] extends Signature ? Key : never;
+}[keyof ObjectType];
+
+/**
+ * Type that represents all method/function names of the given type.
+ */
+export type MethodsOf<
+ ObjectType,
+ Signature extends (...args) => unknown = (...args) => unknown
+> = ReadonlyArray<MethodOf<ObjectType, Signature>>;