aboutsummaryrefslogtreecommitdiff
path: root/src/internal/keys.ts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-12-11 19:42:59 +0100
committerGitHub <[email protected]>2023-12-11 18:42:59 +0000
commit1631115a6a9846c50473fe60ea5bdb7ce9d04084 (patch)
tree6b9dcb203e31aea8ff2233ef60046278139ea71b /src/internal/keys.ts
parent60dcfe7c6454327740d2253ed283deb59d420462 (diff)
downloadfaker-1631115a6a9846c50473fe60ea5bdb7ce9d04084.tar.xz
faker-1631115a6a9846c50473fe60ea5bdb7ce9d04084.zip
infra(tsconfig): noImplicitAny (#2562)
Diffstat (limited to 'src/internal/keys.ts')
-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>;
+}