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.
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +26 -4
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +6 -0
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +20 -4
- package/package.json +1 -1
|
@@ -14919,6 +14919,10 @@ type NumericKeys<TList extends Tuple> = Process$p<TList> extends readonly number
|
|
|
14919
14919
|
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;
|
|
14920
14920
|
/**
|
|
14921
14921
|
* **Get**`<TContainer,TDotPath,[TDefVal]>`
|
|
14922
|
+
*
|
|
14923
|
+
* Provides a type utility which allows reaching into
|
|
14924
|
+
* a container using a _dot path_ to get the type
|
|
14925
|
+
* somewhere inside the parent structure.
|
|
14922
14926
|
*/
|
|
14923
14927
|
type Get$1<TContainer, TDotPath, TDefVal = undefined> = IsNever<_Get<TContainer, TDotPath>> extends true ? TDefVal : _Get<TContainer, TDotPath> extends undefined ? TDefVal : _Get<TContainer, TDotPath>;
|
|
14924
14928
|
|
|
@@ -15245,6 +15249,18 @@ type TruthyReturns<T extends readonly unknown[]> = TupleToUnion<{
|
|
|
15245
15249
|
[K in keyof T]: T[K] extends TypedFunction ? If<IsTruthy<ReturnType<T[K]>>, true, false, boolean> : If<IsTruthy<T[K]>, true, false, boolean>;
|
|
15246
15250
|
}>;
|
|
15247
15251
|
|
|
15252
|
+
/**
|
|
15253
|
+
* Tests whether any of the object in T are explicitly missing
|
|
15254
|
+
* the property P
|
|
15255
|
+
*/
|
|
15256
|
+
type HasMissingInstance<T extends readonly Record<string, unknown>[], P extends string> = [] extends T ? false : P extends keyof First<T> ? HasMissingInstance<AfterFirst<T>, P> : true;
|
|
15257
|
+
/**
|
|
15258
|
+
* removes objects that do not have the property P
|
|
15259
|
+
*/
|
|
15260
|
+
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> ? [
|
|
15261
|
+
...R,
|
|
15262
|
+
First<T>
|
|
15263
|
+
] : R>;
|
|
15248
15264
|
/**
|
|
15249
15265
|
* **UnionFromProp**
|
|
15250
15266
|
*
|
|
@@ -15252,9 +15268,9 @@ type TruthyReturns<T extends readonly unknown[]> = TupleToUnion<{
|
|
|
15252
15268
|
* return a _union type_ of all the potential values of the objects which have
|
|
15253
15269
|
* a keyof `P`.
|
|
15254
15270
|
*
|
|
15255
|
-
* If an object in the array _explicitly_ doesn't have the prop in it's definition
|
|
15256
|
-
* is ignored, if it is shaped to be an optional property then `undefined`
|
|
15257
|
-
* in the union.
|
|
15271
|
+
* If an object in the array _explicitly_ doesn't have the prop in it's definition
|
|
15272
|
+
* then it is ignored, if it is shaped to be an optional property then `undefined`
|
|
15273
|
+
* will be included in the union.
|
|
15258
15274
|
*
|
|
15259
15275
|
* ```ts
|
|
15260
15276
|
* const data = [
|
|
@@ -15265,7 +15281,7 @@ type TruthyReturns<T extends readonly unknown[]> = TupleToUnion<{
|
|
|
15265
15281
|
* type U = UnionFromProp<typeof data, "id">;
|
|
15266
15282
|
* ```
|
|
15267
15283
|
*/
|
|
15268
|
-
type UnionFromProp<T extends readonly Record<string, unknown>[], P extends string> = Get$1<T[number], P>;
|
|
15284
|
+
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>;
|
|
15269
15285
|
|
|
15270
15286
|
type _Keys$2<T extends object> = UnionToTuple$1<keyof RemoveIndexKeys<T>> extends readonly ObjectKey[] ? UnionToTuple$1<keyof RemoveIndexKeys<T>> : never;
|
|
15271
15287
|
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;
|