@gucciogucci/contented
Advanced tools
Comparing version 1.2.0 to 1.2.1
import { ContentedError } from './ContentedError'; | ||
import { ErrorType, ExpectedType, NonFatalErrorType, Type } from './Type'; | ||
export declare function combineIntoObject<E extends ContentedError, O extends Record<string, Type<unknown, E>>>(obj: O): Type<ObjectOf<O>, ErrorTypeInObject<O>>; | ||
declare type ObjectOf<O extends ObjectOfTypes> = IsWithoutNonFatalErrors<O> extends true ? ExpectedTypeInObject<O> : ExpectedTypeInObject<O> | [ExpectedTypeInObject<O>, NonFatalErrorTypesInObject<O>[]]; | ||
export declare function combineIntoObject<E extends ContentedError, O extends Record<string, Type<unknown, E>>>(obj: O): Type<ObjectOf<O>, { [K in keyof O]: ErrorType<O[K]>; }[keyof O]>; | ||
declare type ObjectOf<O extends ObjectOfTypes> = IsWithoutNonFatalErrors<O> extends true ? ExpandRecursively<ExpectedTypeInObject<O>> : ExpandRecursively<ExpectedTypeInObject<O>> | [ExpandRecursively<ExpectedTypeInObject<O>>, NonFatalErrorTypesInObject<O>[]]; | ||
declare type IsWithoutNonFatalErrors<O extends ObjectOfTypes> = NonFatalErrorTypesInObject<O> extends never ? true : false; | ||
@@ -9,9 +9,14 @@ declare type NonFatalErrorTypesInObject<O extends ObjectOfTypes> = { | ||
}[keyof O]; | ||
declare type ExpectedTypeInObject<O extends ObjectOfTypes> = { | ||
declare type ExpectedTypeInObject<O extends ObjectOfTypes> = EnforceOptionality<{ | ||
[K in keyof O]: ExpectedType<O[K]>; | ||
}; | ||
declare type ErrorTypeInObject<O extends ObjectOfTypes> = { | ||
[K in keyof O]: ErrorType<O[K]>; | ||
}>; | ||
declare type ObjectOfTypes = Record<string, Type<unknown, unknown>>; | ||
declare type EnforceOptionality<T> = Optional<T, OptionalKeys<T>>; | ||
declare type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>; | ||
declare type OptionalKeys<O extends {}> = { | ||
[K in keyof O]-?: [O[K] & undefined] extends [never] ? never : K; | ||
}[keyof O]; | ||
declare type ObjectOfTypes = Record<string, Type<unknown, unknown>>; | ||
declare type ExpandRecursively<T> = T extends object ? T extends infer O ? { | ||
[K in keyof O]: ExpandRecursively<O[K]>; | ||
} : never : T; | ||
export {}; |
@@ -35,1 +35,2 @@ "use strict"; | ||
exports.combineIntoObject = combineIntoObject; | ||
// See also: https://stackoverflow.com/a/63990350 |
@@ -1,2 +0,2 @@ | ||
import { ExpectedType, Type } from "./Type"; | ||
import { ExpectedType, Type } from './Type'; | ||
export declare type Infer<T> = [T] extends [Type<infer A, any>] ? ExpectedType<A> : never; |
{ | ||
"name": "@gucciogucci/contented", | ||
"description": "A library to coerce values at run-time.", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"author": "Gucci <npm@gucci.com>", | ||
@@ -6,0 +6,0 @@ "license": "LGPL-3.0-only", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54330
630