type-fest 4.30.1 → 4.30.2

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.30.1",
3
+ "version": "4.30.2",
4
4
  "description": "A collection of essential TypeScript types",
5
5
  "license": "(MIT OR CC0-1.0)",
6
6
  "repository": "sindresorhus/type-fest",
@@ -27,9 +27,11 @@ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
27
27
  @category Object
28
28
  */
29
29
  export type SetOptional<BaseType, Keys extends keyof BaseType> =
30
- Simplify<
31
- // Pick just the keys that are readonly from the base type.
32
- Except<BaseType, Keys> &
33
- // Pick the keys that should be mutable from the base type and make them mutable.
34
- Partial<Pick<BaseType, Keys>>
35
- >;
30
+ BaseType extends unknown // To distribute `BaseType` when it's a union type.
31
+ ? Simplify<
32
+ // Pick just the keys that are readonly from the base type.
33
+ Except<BaseType, Keys> &
34
+ // Pick the keys that should be mutable from the base type and make them mutable.
35
+ Partial<Except<BaseType, Exclude<keyof BaseType, Keys>>>
36
+ >
37
+ : never;
@@ -33,6 +33,6 @@ export type SetReadonly<BaseType, Keys extends keyof BaseType> =
33
33
  BaseType extends unknown
34
34
  ? Simplify<
35
35
  Except<BaseType, Keys> &
36
- Readonly<Pick<BaseType, Keys>>
36
+ Readonly<Except<BaseType, Exclude<keyof BaseType, Keys>>>
37
37
  >
38
38
  : never;
@@ -35,6 +35,6 @@ export type SetRequired<BaseType, Keys extends keyof BaseType> =
35
35
  // Pick just the keys that are optional from the base type.
36
36
  Except<BaseType, Keys> &
37
37
  // Pick the keys that should be required from the base type and make them required.
38
- Required<Pick<BaseType, Keys>>
38
+ Required<Except<BaseType, Exclude<keyof BaseType, Keys>>>
39
39
  >
40
40
  : never;
@@ -63,7 +63,7 @@ function displayPetInfo(petInfo: SharedUnionFields<Cat | Dog>) {
63
63
  @category Object
64
64
  @category Union
65
65
  */
66
- type SharedUnionFields<Union> =
66
+ export type SharedUnionFields<Union> =
67
67
  Extract<Union, NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | UnknownArray> extends infer SkippedMembers
68
68
  ? Exclude<Union, SkippedMembers> extends infer RelevantMembers
69
69
  ?