@@ -2,6 +2,7 @@ import type {
22 Closure ,
33 ClosureArgs ,
44 Equals ,
5+ GetClosureArgs ,
56 GetObjectMethods ,
67 KeyOf ,
78 Pretty ,
@@ -12,7 +13,12 @@ import type { Constructor } from '@noeldemartin/utils/types/classes';
1213import type { DeepKeyOf , DeepValue } from '@noeldemartin/utils/types' ;
1314
1415export type Obj = Record < string , unknown > ;
15- export type ObjectEntry < T extends Obj , K extends keyof T > = [ K , T [ K ] ] ;
16+
17+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18+ export type GetObjectKeys < T > = T extends Record < infer Key , any > ? Key : keyof T ;
19+
20+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21+ export type GetObjectValues < T > = T extends Record < any , infer Value > ? Value : never ;
1622
1723export type ValueWithout < TValue , TExclude > = TValue extends TExclude ? never : TValue ;
1824export type ReplaceValues < TObj , TExclude > = { [ K in keyof TObj ] : ValueWithout < TObj [ K ] , TExclude > } ;
@@ -169,7 +175,9 @@ export function objectDeepValue<T extends object, K extends DeepKeyOf<T>>(object
169175 return value as DeepValue < T , K > ;
170176}
171177
172- export const objectEntries = Object . entries . bind ( Object ) as < T extends Obj > ( obj : T ) => ObjectEntry < T , keyof T > [ ] ;
178+ export const objectEntries = Object . entries . bind ( Object ) as < T extends GetClosureArgs < typeof Object . entries > [ 0 ] > (
179+ obj : T
180+ ) => [ GetObjectKeys < T > , GetObjectValues < T > ] [ ] ;
173181
174182export function objectHasOwnProperty ( object : Obj , property : string ) : boolean {
175183 return Object . prototype . hasOwnProperty . call ( object , property ) ;
0 commit comments