type-fest 4.10.2 → 4.10.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
package/source/internal.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type {Primitive} from './primitive';
|
|
|
2
2
|
import type {Simplify} from './simplify';
|
|
3
3
|
import type {Trim} from './trim';
|
|
4
4
|
import type {IsAny} from './is-any';
|
|
5
|
+
import type {IsLiteral} from './is-literal';
|
|
5
6
|
import type {UnknownRecord} from './unknown-record';
|
|
6
7
|
import type {IsNever} from './is-never';
|
|
7
8
|
import type {UnknownArray} from './unknown-array';
|
|
@@ -357,6 +358,11 @@ IsPrimitive<Object>
|
|
|
357
358
|
*/
|
|
358
359
|
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
359
360
|
|
|
361
|
+
/**
|
|
362
|
+
Utility type to retrieve only literal keys from type.
|
|
363
|
+
*/
|
|
364
|
+
export type LiteralKeyOf<T> = keyof {[K in keyof T as IsLiteral<K> extends true ? K : never]-?: never};
|
|
365
|
+
|
|
360
366
|
/**
|
|
361
367
|
Returns the static, fixed-length portion of the given array, excluding variable-length parts.
|
|
362
368
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {IfUnknown} from './if-unknown';
|
|
2
|
+
import type {BuiltIns, LiteralKeyOf} from './internal';
|
|
2
3
|
import type {Merge} from './merge';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -47,8 +48,8 @@ const testSettings: PartialOnUndefinedDeep<Settings> = {
|
|
|
47
48
|
@category Object
|
|
48
49
|
*/
|
|
49
50
|
export type PartialOnUndefinedDeep<T, Options extends PartialOnUndefinedDeepOptions = {}> = T extends Record<any, any> | undefined
|
|
50
|
-
? {[KeyType in keyof T as undefined extends T[KeyType] ? KeyType : never]?: PartialOnUndefinedDeepValue<T[KeyType], Options>} extends infer U // Make a partial type with all value types accepting undefined (and set them optional)
|
|
51
|
-
? Merge<{[KeyType in keyof T as KeyType extends
|
|
51
|
+
? {[KeyType in keyof T as undefined extends T[KeyType] ? IfUnknown<T[KeyType], never, KeyType> : never]?: PartialOnUndefinedDeepValue<T[KeyType], Options>} extends infer U // Make a partial type with all value types accepting undefined (and set them optional)
|
|
52
|
+
? Merge<{[KeyType in keyof T as KeyType extends LiteralKeyOf<U> ? never : KeyType]: PartialOnUndefinedDeepValue<T[KeyType], Options>}, U> // Join all remaining keys not treated in U
|
|
52
53
|
: never // Should not happen
|
|
53
54
|
: T;
|
|
54
55
|
|