From efe1c8e4fddf5b2e5e5df59bff39cec29919aa10 Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Tue, 14 Feb 2023 02:17:45 +0000 Subject: [PATCH] feat(values): improve type signature of "values" function BREAKING CHANGE: The function "values" has a new, incompatible type signature. --- index.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/index.ts b/index.ts index d22ebe5..80c96a5 100644 --- a/index.ts +++ b/index.ts @@ -38,9 +38,7 @@ export function copy(object: T): T { } /** The string property names of `T`. */ -export type StringKey = T extends Record - ? K & string - : never; +export type StringKey = T extends Record ? K & string : never; /** Returns an array of the object's own ennumerable string-keyed property names. */ // @ts-ignore duplicate identifier: This is the exported declaration, the implementation is below. @@ -50,16 +48,21 @@ export function keys(object: T): Array>; // @ts-ignore duplicate identifier: This is the actual implementation, the exported declaration is above. export const keys: (object: T) => Array> = Object.keys; +/** The string-keyed property values of `T`. */ +export type StringKeyedValue = T extends Record + ? K extends string + ? T[K] + : never + : never; + +/** Returns an array of the object's own ennumerable string-keyed property + * values. */ // @ts-ignore duplicate identifier: This is the exported declaration, the implementation is below. -export function values( - dictionary: Readonly> -): TValue[]; +export function values(object: T): Array>; /* @internal This implementation is for internal use only, the exported declaration is above. */ // @ts-ignore duplicate identifier: This is the actual implementation, the exported declaration is above. -export const values: ( - dictionary: Readonly> -) => TValue[] = Object.values; +export const values: (object: T) => Array> = Object.values; // @ts-ignore duplicate identifier: This is the exported declaration, the implementation is below. export function entries(