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
package/source/set-optional.d.ts
CHANGED
|
@@ -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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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;
|
package/source/set-readonly.d.ts
CHANGED
package/source/set-required.d.ts
CHANGED
|
@@ -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<
|
|
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
|
?
|