type-fest 4.39.0 → 4.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-fest",
3
- "version": "4.39.0",
3
+ "version": "4.39.1",
4
4
  "description": "A collection of essential TypeScript types",
5
5
  "license": "(MIT OR CC0-1.0)",
6
6
  "repository": "sindresorhus/type-fest",
@@ -1,5 +1,3 @@
1
- import type {KeysOfUnion} from './keys-of-union';
2
-
3
1
  /**
4
2
  Extract all optional keys from the given type.
5
3
 
@@ -33,6 +31,9 @@ const update2: UpdateOperation<User> = {
33
31
 
34
32
  @category Utilities
35
33
  */
36
- export type OptionalKeysOf<BaseType extends object> = KeysOfUnion<{
37
- [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
38
- }>;
34
+ export type OptionalKeysOf<BaseType extends object> =
35
+ BaseType extends unknown // For distributing `BaseType`
36
+ ? (keyof {
37
+ [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
38
+ }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
39
+ : never; // Should never happen
@@ -1,5 +1,4 @@
1
1
  import type {IsEqual} from './is-equal';
2
- import type {KeysOfUnion} from './keys-of-union';
3
2
 
4
3
  /**
5
4
  Extract all writable keys from the given type.
@@ -26,6 +25,9 @@ const update1: UpdateRequest<User> = {
26
25
 
27
26
  @category Utilities
28
27
  */
29
- export type WritableKeysOf<T> = KeysOfUnion<{
30
- [P in keyof T as IsEqual<{[Q in P]: T[P]}, {readonly [Q in P]: T[P]}> extends false ? P : never]: never
31
- }>;
28
+ export type WritableKeysOf<T> =
29
+ T extends unknown // For distributing `T`
30
+ ? (keyof {
31
+ [P in keyof T as IsEqual<{[Q in P]: T[P]}, {readonly [Q in P]: T[P]}> extends false ? P : never]: never
32
+ }) & keyof T // Intersect with `keyof T` to ensure result of `WritableKeysOf<T>` is always assignable to `keyof T`
33
+ : never; // Should never happen