diff --git a/source/object-keys.ts b/source/object-keys.ts index 29fe713..9c123bc 100644 --- a/source/object-keys.ts +++ b/source/object-keys.ts @@ -1,4 +1,6 @@ -export type ObjectKeys> = `${Exclude}`; +/* eslint-disable @typescript-eslint/ban-types */ + +export type ObjectKeys = `${Exclude}`; /** A strongly-typed version of `Object.keys()`. @@ -19,6 +21,6 @@ const untypedItems = Object.keys(items); // => Array @category Improved builtin @category Type guard */ -export function objectKeys>(value: Type): Array> { +export function objectKeys(value: Type): Array> { return Object.keys(value) as Array>; } diff --git a/test/object-keys.ts b/test/object-keys.ts index a177db5..b41a9e5 100644 --- a/test/object-keys.ts +++ b/test/object-keys.ts @@ -2,10 +2,19 @@ import test from 'ava'; import {expectTypeOf} from 'expect-type'; import {objectKeys} from '../source/index.js'; +interface TestInterface { + e: string; + f: number; +} + test('objectKeys()', t => { type Item = 'a' | 'b' | 'c' | '4'; const items = objectKeys({a: 1, b: 2, c: 3, 4: 4, [Symbol('5')]: 5}); - expectTypeOf(items); t.deepEqual(items, ['4', 'a', 'b', 'c']); + + const interfaceInput: TestInterface = {e: 'a', f: 1}; + const interfaceItems = objectKeys(interfaceInput); + expectTypeOf>(interfaceItems); + t.deepEqual(interfaceItems, ['e', 'f']); });