type-fest 5.4.0 → 5.4.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 +1 -1
- package/source/merge-deep.d.ts +2 -2
- package/source/merge.d.ts +10 -6
- package/source/simplify-deep.d.ts +2 -1
package/package.json
CHANGED
package/source/merge-deep.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ type MergeDeepRecordProperty<
|
|
|
33
33
|
Source,
|
|
34
34
|
Options extends MergeDeepInternalOptions,
|
|
35
35
|
> = undefined extends Source
|
|
36
|
-
? MergeDeepOrReturn<Source, Exclude<Destination, undefined>, Exclude<Source, undefined>, Options> | undefined
|
|
36
|
+
? MergeDeepOrReturn<Source, Exclude<Destination, undefined>, Exclude<Source, undefined>, Options> | (undefined extends Destination ? undefined : never)
|
|
37
37
|
: MergeDeepOrReturn<Source, Destination, Source, Options>;
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -58,7 +58,7 @@ type DoMergeDeepRecord<
|
|
|
58
58
|
}
|
|
59
59
|
// Case in rule 3: Both the source and the destination contain the key.
|
|
60
60
|
& {
|
|
61
|
-
[Key in keyof Source as Key extends keyof Destination ? Key : never]: MergeDeepRecordProperty<Destination[Key], Source[Key], Options>;
|
|
61
|
+
[Key in keyof Source as Key extends keyof Destination ? Key : never]: MergeDeepRecordProperty<Required<Destination>[Key], Required<Source>[Key], Options>;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
/**
|
package/source/merge.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import type {PickIndexSignature} from './pick-index-signature.d.ts';
|
|
|
3
3
|
import type {Simplify} from './simplify.d.ts';
|
|
4
4
|
|
|
5
5
|
// Merges two objects without worrying about index signatures.
|
|
6
|
-
type SimpleMerge<Destination, Source> = {
|
|
6
|
+
type SimpleMerge<Destination, Source> = Simplify<{
|
|
7
7
|
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
8
|
-
} & Source
|
|
8
|
+
} & Source>;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
@@ -45,9 +45,13 @@ Note: If you want a merge type that more accurately reflects the runtime behavio
|
|
|
45
45
|
@category Object
|
|
46
46
|
*/
|
|
47
47
|
export type Merge<Destination, Source> =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
Destination extends unknown // For distributing `Destination`
|
|
49
|
+
? Source extends unknown // For distributing `Source`
|
|
50
|
+
? Simplify<
|
|
51
|
+
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
|
|
52
|
+
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
|
|
53
|
+
>
|
|
54
|
+
: never // Should never happen
|
|
55
|
+
: never; // Should never happen
|
|
52
56
|
|
|
53
57
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {ConditionalSimplifyDeep} from './conditional-simplify-deep.d.ts';
|
|
2
2
|
import type {MapsSetsOrArrays, NonRecursiveType} from './internal/index.d.ts';
|
|
3
|
+
import type {UnknownArray} from './unknown-array.d.ts';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
Deeply simplifies an object type.
|
|
@@ -109,7 +110,7 @@ type SimplifyDeepProperties = SimplifyDeep<Properties1 & Properties2, ComplexTyp
|
|
|
109
110
|
export type SimplifyDeep<Type, ExcludeType = never> =
|
|
110
111
|
ConditionalSimplifyDeep<
|
|
111
112
|
Type,
|
|
112
|
-
ExcludeType | NonRecursiveType | MapsSetsOrArrays,
|
|
113
|
+
ExcludeType | NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray>,
|
|
113
114
|
object
|
|
114
115
|
>;
|
|
115
116
|
|