type-fest
Advanced tools
Comparing version 4.10.2 to 4.10.3
{ | ||
"name": "type-fest", | ||
"version": "4.10.2", | ||
"version": "4.10.3", | ||
"description": "A collection of essential TypeScript types", | ||
@@ -5,0 +5,0 @@ "license": "(MIT OR CC0-1.0)", |
@@ -5,2 +5,3 @@ import type {Primitive} from './primitive'; | ||
import type {IsAny} from './is-any'; | ||
import type {IsLiteral} from './is-literal'; | ||
import type {UnknownRecord} from './unknown-record'; | ||
@@ -362,2 +363,7 @@ import type {IsNever} from './is-never'; | ||
/** | ||
Utility type to retrieve only literal keys from type. | ||
*/ | ||
export type LiteralKeyOf<T> = keyof {[K in keyof T as IsLiteral<K> extends true ? K : never]-?: never}; | ||
/** | ||
Returns the static, fixed-length portion of the given array, excluding variable-length parts. | ||
@@ -364,0 +370,0 @@ |
@@ -1,2 +0,3 @@ | ||
import type {BuiltIns} from './internal'; | ||
import type {IfUnknown} from './if-unknown'; | ||
import type {BuiltIns, LiteralKeyOf} from './internal'; | ||
import type {Merge} from './merge'; | ||
@@ -50,4 +51,4 @@ | ||
export type PartialOnUndefinedDeep<T, Options extends PartialOnUndefinedDeepOptions = {}> = T extends Record<any, any> | undefined | ||
? {[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) | ||
? Merge<{[KeyType in keyof T as KeyType extends keyof U ? never : KeyType]: PartialOnUndefinedDeepValue<T[KeyType], Options>}, U> // Join all remaining keys not treated in U | ||
? {[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) | ||
? 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 | ||
: never // Should not happen | ||
@@ -54,0 +55,0 @@ : T; |
320394
7529