inferred-types 0.53.6 → 0.53.7

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.
@@ -14168,6 +14168,10 @@ type NumericKeys$1<TList extends Tuple$1> = Process$p$1<TList> extends readonly
14168
14168
  type _Get$1<T, K, Acc = never> = K extends `${infer A}.${infer B}` ? A extends keyof T ? _Get$1<T[A], B, _Get$1<T[A], B>> : Acc : K extends keyof T ? _Get$1<T[K], K, T[K]> : Acc;
14169
14169
  /**
14170
14170
  * **Get**`<TContainer,TDotPath,[TDefVal]>`
14171
+ *
14172
+ * Provides a type utility which allows reaching into
14173
+ * a container using a _dot path_ to get the type
14174
+ * somewhere inside the parent structure.
14171
14175
  */
14172
14176
  type Get$1$1<TContainer, TDotPath, TDefVal = undefined> = IsNever$1<_Get$1<TContainer, TDotPath>> extends true ? TDefVal : _Get$1<TContainer, TDotPath> extends undefined ? TDefVal : _Get$1<TContainer, TDotPath>;
14173
14177
 
@@ -15751,6 +15755,8 @@ declare function createFnWithProps<TArgs extends readonly unknown[], TReturn ext
15751
15755
  * // { foo: 1; bar: number; baz: number }
15752
15756
  * const fooBarBaz = defineObj({foo: 1})({bar: 2, baz: 3});
15753
15757
  * ```
15758
+ *
15759
+ * **Related:** `defineObject`
15754
15760
  */
15755
15761
  declare function defineObj<N extends Narrowable$1, TLiteral extends Record<string, N>>(literal?: TLiteral): <N2 extends Narrowable$1, TWide extends Record<string, N2>>(wide?: TWide) => ExpandDictionary$1<RemoveIndex$1<TLiteral> & (IsNonEmptyObject$1<TWide> extends true ? Widen$1<TWide> : EmptyObject$1)>;
15756
15762
 
@@ -33403,6 +33409,10 @@ type NumericKeys<TList extends Tuple> = Process$p<TList> extends readonly number
33403
33409
  type _Get<T, K, Acc = never> = K extends `${infer A}.${infer B}` ? A extends keyof T ? _Get<T[A], B, _Get<T[A], B>> : Acc : K extends keyof T ? _Get<T[K], K, T[K]> : Acc;
33404
33410
  /**
33405
33411
  * **Get**`<TContainer,TDotPath,[TDefVal]>`
33412
+ *
33413
+ * Provides a type utility which allows reaching into
33414
+ * a container using a _dot path_ to get the type
33415
+ * somewhere inside the parent structure.
33406
33416
  */
33407
33417
  type Get$1<TContainer, TDotPath, TDefVal = undefined> = IsNever<_Get<TContainer, TDotPath>> extends true ? TDefVal : _Get<TContainer, TDotPath> extends undefined ? TDefVal : _Get<TContainer, TDotPath>;
33408
33418
 
@@ -33729,6 +33739,18 @@ type TruthyReturns<T extends readonly unknown[]> = TupleToUnion<{
33729
33739
  [K in keyof T]: T[K] extends TypedFunction ? If<IsTruthy<ReturnType<T[K]>>, true, false, boolean> : If<IsTruthy<T[K]>, true, false, boolean>;
33730
33740
  }>;
33731
33741
 
33742
+ /**
33743
+ * Tests whether any of the object in T are explicitly missing
33744
+ * the property P
33745
+ */
33746
+ type HasMissingInstance<T extends readonly Record<string, unknown>[], P extends string> = [] extends T ? false : P extends keyof First<T> ? HasMissingInstance<AfterFirst<T>, P> : true;
33747
+ /**
33748
+ * removes objects that do not have the property P
33749
+ */
33750
+ type RemoveMissing<T extends readonly Record<string, unknown>[], P extends string, R extends readonly Record<string, unknown>[] = []> = [] extends T ? R[number] : RemoveMissing<AfterFirst<T>, P, P extends keyof First<T> ? [
33751
+ ...R,
33752
+ First<T>
33753
+ ] : R>;
33732
33754
  /**
33733
33755
  * **UnionFromProp**
33734
33756
  *
@@ -33736,9 +33758,9 @@ type TruthyReturns<T extends readonly unknown[]> = TupleToUnion<{
33736
33758
  * return a _union type_ of all the potential values of the objects which have
33737
33759
  * a keyof `P`.
33738
33760
  *
33739
- * If an object in the array _explicitly_ doesn't have the prop in it's definition then it
33740
- * is ignored, if it is shaped to be an optional property then `undefined` will be included
33741
- * in the union.
33761
+ * If an object in the array _explicitly_ doesn't have the prop in it's definition
33762
+ * then it is ignored, if it is shaped to be an optional property then `undefined`
33763
+ * will be included in the union.
33742
33764
  *
33743
33765
  * ```ts
33744
33766
  * const data = [
@@ -33749,7 +33771,7 @@ type TruthyReturns<T extends readonly unknown[]> = TupleToUnion<{
33749
33771
  * type U = UnionFromProp<typeof data, "id">;
33750
33772
  * ```
33751
33773
  */
33752
- type UnionFromProp<T extends readonly Record<string, unknown>[], P extends string> = Get$1<T[number], P>;
33774
+ type UnionFromProp<T extends readonly Record<string, unknown>[], P extends string> = HasMissingInstance<T, P> extends true ? Get$1<RemoveMissing<T, P>, P> | undefined : Get$1<T[number], P>;
33753
33775
 
33754
33776
  type _Keys$2<T extends object> = UnionToTuple$1<keyof RemoveIndexKeys<T>> extends readonly ObjectKey[] ? UnionToTuple$1<keyof RemoveIndexKeys<T>> : never;
33755
33777
  type ProcessObj$1<T extends Container, TKeys extends readonly PropertyKey[], TResults extends Dictionary = EmptyObject> = [] extends TKeys ? TResults : First<TKeys> extends keyof T ? IfNever<T[First<TKeys>], ProcessObj$1<T, AfterFirst<TKeys>, TResults>, ProcessObj$1<T, AfterFirst<TKeys>, First<TKeys> extends keyof T ? TResults extends readonly unknown[] ? [...TResults, T[First<TKeys>]] : TResults extends Dictionary ? TResults & Record<First<TKeys>, T[First<TKeys>]> : never : never>> : never;