Skip to content

Commit

Permalink
feat: update Object.entries types
Browse files Browse the repository at this point in the history
Added an optional generic type with string as the default type for the object argument in Object.entries. This makes the typing of this function “end-to-end”. For example, if Record<“value1” | “value2”, string> is passed as an argument, the output value will be [“value1” | “value2”, string][]
  • Loading branch information
nezo32 authored Jan 29, 2025
1 parent 0652664 commit 2d2264e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/es2017.object.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ObjectConstructor {
* Returns an array of key/values of the enumerable own properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
entries<T>(o: { [s: string]: T; } | ArrayLike<T>): [string, T][];
entries<T, K extends string = string>(o: { [Key in K]: T; } | ArrayLike<T>): [K, T][];

/**
* Returns an array of key/values of the enumerable own properties of an object
Expand Down

0 comments on commit 2d2264e

Please sign in to comment.