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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-fest",
3
- "version": "4.8.2",
3
+ "version": "4.8.3",
4
4
  "description": "A collection of essential TypeScript types",
5
5
  "license": "(MIT OR CC0-1.0)",
6
6
  "repository": "sindresorhus/type-fest",
@@ -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
- - If the source does not contain the key, the value of the destination is returned.
34
- - If the source contains the key and the destination does not contain the key, the value of the source is returned.
35
- - If both contain the key, try to merge according to the chosen {@link MergeDeepOptions options} or return the source if unable to merge.
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
- > = EnforceOptional<{
42
- [Key in keyof Destination | keyof Source]: Key extends keyof Source
43
- ? Key extends keyof Destination
44
- ? MergeDeepRecordProperty<Destination[Key], Source[Key], Options>
45
- : Source[Key]
46
- : Key extends keyof Destination
47
- ? Destination[Key]
48
- : never;
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.