aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/internal/keys.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/internal/keys.ts b/src/internal/keys.ts
new file mode 100644
index 00000000..d67d32e7
--- /dev/null
+++ b/src/internal/keys.ts
@@ -0,0 +1,13 @@
+/**
+ * Specialized version of `Object.keys()` which preserves the type information of the keys.
+ *
+ * Please note that the type information might be inaccurate for subtypes of the argument type
+ * and thus should only be used to cover the property access of the object.
+ *
+ * @internal
+ *
+ * @param obj The object to get the keys of.
+ */
+export function keys<T extends object>(obj: T): Array<keyof T> {
+ return Object.keys(obj) as Array<keyof T>;
+}