From 2d2264e8431c22ce370e82278dab4910c8a07f3e Mon Sep 17 00:00:00 2001 From: nezo <56090617+nezo32@users.noreply.github.com> Date: Wed, 29 Jan 2025 21:04:27 +0300 Subject: [PATCH 1/2] feat: update Object.entries types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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][] --- src/lib/es2017.object.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2017.object.d.ts b/src/lib/es2017.object.d.ts index 5b76938b69b03..48a1982925fcc 100644 --- a/src/lib/es2017.object.d.ts +++ b/src/lib/es2017.object.d.ts @@ -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(o: { [s: string]: T; } | ArrayLike): [string, T][]; + entries(o: { [Key in K]: T; } | ArrayLike): [K, T][]; /** * Returns an array of key/values of the enumerable own properties of an object From d3471e2640f4edef041974718717f81fd6f39f94 Mon Sep 17 00:00:00 2001 From: nezo <56090617+nezo32@users.noreply.github.com> Date: Wed, 29 Jan 2025 21:08:52 +0300 Subject: [PATCH 2/2] feat: update Object.fromEntries types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added an optional generic type with PropertyKey as the default type for the object argument in Object.fromEntries. This makes the typing of this function “end-to-end”. For example, if [ “value1” | “value2”, string ][] is passed as an argument, the output value will be { [Key in “value1” | “value2”]: string } --- src/lib/es2019.object.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2019.object.d.ts b/src/lib/es2019.object.d.ts index ed8e9777f01e2..72388b725d21b 100644 --- a/src/lib/es2019.object.d.ts +++ b/src/lib/es2019.object.d.ts @@ -5,7 +5,7 @@ interface ObjectConstructor { * Returns an object created by key-value entries for properties and methods * @param entries An iterable object that contains key-value entries for properties and methods. */ - fromEntries(entries: Iterable): { [k: string]: T; }; + fromEntries(entries: Iterable): { [Key in K]: T; }; /** * Returns an object created by key-value entries for properties and methods