type-fest 4.8.2 → 4.8.3
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 +17 -13
- package/source/paths.d.ts +1 -1
- package/source/writable-deep.d.ts +0 -1
package/package.json
CHANGED
package/source/merge-deep.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type {ConditionalSimplifyDeep} from './conditional-simplify';
|
|
2
2
|
import type {OmitIndexSignature} from './omit-index-signature';
|
|
3
3
|
import type {PickIndexSignature} from './pick-index-signature';
|
|
4
|
-
import type {EnforceOptional} from './enforce-optional';
|
|
5
4
|
import type {Merge} from './merge';
|
|
6
5
|
import type {
|
|
7
6
|
ArrayTail,
|
|
@@ -30,23 +29,28 @@ type MergeDeepRecordProperty<
|
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
Walk through the union of the keys of the two objects and test in which object the properties are defined.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
Rules:
|
|
33
|
+
1. If the source does not contain the key, the value of the destination is returned.
|
|
34
|
+
2. If the source contains the key and the destination does not contain the key, the value of the source is returned.
|
|
35
|
+
3. If both contain the key, try to merge according to the chosen {@link MergeDeepOptions options} or return the source if unable to merge.
|
|
36
36
|
*/
|
|
37
37
|
type DoMergeDeepRecord<
|
|
38
38
|
Destination extends UnknownRecord,
|
|
39
39
|
Source extends UnknownRecord,
|
|
40
40
|
Options extends MergeDeepInternalOptions,
|
|
41
|
-
> =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
41
|
+
> =
|
|
42
|
+
// Case in rule 1: The destination contains the key but the source doesn't.
|
|
43
|
+
{
|
|
44
|
+
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
45
|
+
}
|
|
46
|
+
// Case in rule 2: The source contains the key but the destination doesn't.
|
|
47
|
+
& {
|
|
48
|
+
[Key in keyof Source as Key extends keyof Destination ? never : Key]: Source[Key];
|
|
49
|
+
}
|
|
50
|
+
// Case in rule 3: Both the source and the destination contain the key.
|
|
51
|
+
& {
|
|
52
|
+
[Key in keyof Source as Key extends keyof Destination ? Key : never]: MergeDeepRecordProperty<Destination[Key], Source[Key], Options>;
|
|
53
|
+
};
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
56
|
Wrapper around {@link DoMergeDeepRecord} which preserves index signatures.
|
package/source/paths.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ open('listB.1'); // TypeError. Because listB only has one element.
|
|
|
78
78
|
@category Array
|
|
79
79
|
*/
|
|
80
80
|
export type Paths<T> =
|
|
81
|
-
T extends NonRecursiveType
|
|
81
|
+
T extends NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>
|
|
82
82
|
? never
|
|
83
83
|
: IsAny<T> extends true
|
|
84
84
|
? never
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {BuiltIns, HasMultipleCallSignatures} from './internal';
|
|
2
|
-
import type {Writable} from './writable.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
Create a deeply mutable version of an `object`/`ReadonlyMap`/`ReadonlySet`/`ReadonlyArray` type. The inverse of `ReadonlyDeep<T>`. Use `Writable<T>` if you only need one level deep.
|