@@ -1288,16 +1288,26 @@ export function isDefined<T>(value: T | null | undefined): value is T {
12881288 return value !== undefined && value !== null ;
12891289}
12901290
1291- /** Like `Object.keys`, but infers the correct key type. */
1292- export function keysTyped < T extends Record < string , any > > (
1291+ /** Like `Object.keys`, but typed so that the elements of the resulting array have the
1292+ * same type as the keys of the input object. Note that this may not be sound if the input
1293+ * object has been cast to `T` from a subtype of `T` and contains additional keys that
1294+ * are not represented by `keyof T`.
1295+ */
1296+ export function unsafeKeysInvariant < T extends Record < string , any > > (
12931297 object : T ,
12941298) : Array < keyof T > {
12951299 return Object . keys ( object ) as Array < keyof T > ;
12961300}
12971301
1298- /** Like `Object.entries`, but infers the correct key type. */
1299- export function entriesTyped < T extends Record < string , any > > (
1302+ /** Like `Object.entries`, but typed so that the key elements of the result have the
1303+ * same type as the keys of the input object. Note that this may not be sound if the input
1304+ * object has been cast to `T` from a subtype of `T` and contains additional keys that
1305+ * are not represented by `keyof T`.
1306+ */
1307+ export function unsafeEntriesInvariant < T extends Record < string , any > > (
13001308 object : T ,
1301- ) : Array < [ keyof T , NonNullable < T [ keyof T ] > ] > {
1302- return Object . entries ( object ) as Array < [ keyof T , NonNullable < T [ keyof T ] > ] > ;
1309+ ) : Array < [ keyof T , Exclude < T [ keyof T ] , undefined > ] > {
1310+ return Object . entries ( object ) as Array <
1311+ [ keyof T , Exclude < T [ keyof T ] , undefined > ]
1312+ > ;
13031313}
0 commit comments