diff --git a/src/objectKeys.ts b/src/objectKeys.ts index 0370131..00f1df6 100644 --- a/src/objectKeys.ts +++ b/src/objectKeys.ts @@ -1,4 +1,4 @@ /** https://docs.tsafe.dev/objectKeys */ -export function objectKeys>(o: T): (keyof T)[] { +export function objectKeys>(o: T): (keyof T & string)[] { return Object.keys(o) as any; } diff --git a/test/objectKeys.ts b/test/objectKeys.ts index 067fa90..97c9205 100644 --- a/test/objectKeys.ts +++ b/test/objectKeys.ts @@ -39,3 +39,19 @@ import { same } from "evt/tools/inDepth/same"; console.log("PASS TEST 2"); } + +{ + type A = { + [key: string]: boolean; + }; + + const a: A = { isNormalUser: false, isAdmin: true }; + + const got = objectKeys(a); + + const expected = ["isNormalUser", "isAdmin"]; + + assert(same(got, expected)); + + console.log("PASS TEST 3"); +}