From 75caf4489465b7af770508f0b82f48f382470a59 Mon Sep 17 00:00:00 2001 From: Robin Kneepkens Date: Mon, 18 Nov 2024 17:08:27 +0100 Subject: [PATCH] Updated API docs. --- etc/types.api.md | 119 ++++---------- markdown/types.autocast.md | 27 --- markdown/types.autocastall.md | 27 --- markdown/types.autocastfailure.md | 13 -- markdown/types.baseobjectliketypeimpl.and.md | 2 +- markdown/types.baseobjectliketypeimpl.md | 14 +- ...types.baseobjectliketypeimpl.propsarray.md | 2 +- ...ypes.basetypeimpl.createautocastalltype.md | 4 +- .../types.basetypeimpl.customvalidators.md | 17 -- markdown/types.basetypeimpl.md | 21 +-- markdown/types.basetypeimpl.withconstraint.md | 2 +- markdown/types.booleanautocaster.md | 2 +- markdown/types.brands.md | 13 -- markdown/types.createtype.md | 10 +- markdown/types.deepunbranded.md | 19 ++- markdown/types.designtype.md | 13 -- markdown/types.fulltype.md | 6 +- markdown/types.interfacemergeoptions.md | 21 --- markdown/types.interfacemergeoptions.name.md | 19 --- ...types.interfacemergeoptions.omitparsers.md | 21 --- ...s.interfacemergeoptions.omitvalidations.md | 23 --- .../types.interfacepickoptions.applyparser.md | 21 --- markdown/types.interfacepickoptions.md | 21 --- markdown/types.interfacepickoptions.name.md | 19 --- ...es.interfacepickoptions.omitvalidations.md | 21 --- markdown/types.interfacetype._constructor_.md | 10 +- markdown/types.interfacetype.keys.md | 2 +- markdown/types.interfacetype.md | 14 +- markdown/types.interfacetype.mergewith.md | 27 --- markdown/types.interfacetype.omit.md | 23 --- markdown/types.interfacetype.pick.md | 23 --- markdown/types.interfacetype.withoptional.md | 16 +- markdown/types.interfacetype.withrequired.md | 29 ---- markdown/types.interfacetypeoptions.md | 1 + .../types.interfacetypeoptionswithpartial.md | 19 --- ...interfacetypeoptionswithpartial.partial.md | 21 --- markdown/types.intersectionoftypetuple.md | 2 +- markdown/types.md | 154 ++++++++---------- markdown/types.mergeintersection.md | 8 +- markdown/types.mergetype.md | 17 -- markdown/types.numberautocaster.md | 2 +- markdown/types.object.md | 8 +- markdown/types.partial.md | 8 +- markdown/types.partialtype.md | 6 +- markdown/types.picktype.md | 17 -- markdown/types.propertiesinfo.md | 7 +- markdown/types.propertyinfo.md | 18 -- markdown/types.simpleacceptvisitor.md | 13 -- markdown/types.simpletypeoptions.md | 2 +- markdown/types.simplify.md | 15 -- markdown/types.typeof.md | 2 - markdown/types.unbrandvalues.md | 15 -- markdown/types.validationerror.details.md | 2 +- markdown/types.validationerror.input.md | 2 +- markdown/types.validationerror.md | 6 +- markdown/types.validationerror.type.md | 2 +- markdown/types.validationresult.md | 4 +- markdown/types.withbrands.md | 2 - src/types/intersection.ts | 5 +- src/types/number.ts | 2 +- src/types/record.ts | 7 +- src/types/union.ts | 5 +- 62 files changed, 198 insertions(+), 795 deletions(-) delete mode 100644 markdown/types.autocast.md delete mode 100644 markdown/types.autocastall.md delete mode 100644 markdown/types.autocastfailure.md delete mode 100644 markdown/types.basetypeimpl.customvalidators.md delete mode 100644 markdown/types.brands.md delete mode 100644 markdown/types.designtype.md delete mode 100644 markdown/types.interfacemergeoptions.md delete mode 100644 markdown/types.interfacemergeoptions.name.md delete mode 100644 markdown/types.interfacemergeoptions.omitparsers.md delete mode 100644 markdown/types.interfacemergeoptions.omitvalidations.md delete mode 100644 markdown/types.interfacepickoptions.applyparser.md delete mode 100644 markdown/types.interfacepickoptions.md delete mode 100644 markdown/types.interfacepickoptions.name.md delete mode 100644 markdown/types.interfacepickoptions.omitvalidations.md delete mode 100644 markdown/types.interfacetype.mergewith.md delete mode 100644 markdown/types.interfacetype.omit.md delete mode 100644 markdown/types.interfacetype.pick.md delete mode 100644 markdown/types.interfacetype.withrequired.md delete mode 100644 markdown/types.interfacetypeoptionswithpartial.md delete mode 100644 markdown/types.interfacetypeoptionswithpartial.partial.md delete mode 100644 markdown/types.mergetype.md delete mode 100644 markdown/types.picktype.md delete mode 100644 markdown/types.propertyinfo.md delete mode 100644 markdown/types.simpleacceptvisitor.md delete mode 100644 markdown/types.simplify.md delete mode 100644 markdown/types.unbrandvalues.md diff --git a/etc/types.api.md b/etc/types.api.md index 1b5e561..5b25d64 100644 --- a/etc/types.api.md +++ b/etc/types.api.md @@ -32,15 +32,6 @@ export interface ArrayTypeConfig extends LengthChecksConfig { // @public export type ArrayViolation = LengthViolation; -// @public -export function autoCast>(type: T): T; - -// @public -export function autoCastAll>(type: T): T; - -// @public -export const autoCastFailure: unique symbol; - // @public export abstract class BaseObjectLikeTypeImpl extends BaseTypeImpl { and>(_other: Other): ObjectType> & TypedPropertyInformation; @@ -50,7 +41,7 @@ export abstract class BaseObjectLikeTypeImpl e abstract readonly possibleDiscriminators: readonly PossibleDiscriminator[]; // (undocumented) abstract readonly props: Properties; - protected get propsArray(): ReadonlyArray<[string, PropertyInfo]>; + protected get propsArray(): ReadonlyArray<[string, Type]>; // (undocumented) abstract readonly propsInfo: PropertiesInfo; } @@ -62,15 +53,16 @@ export abstract class BaseTypeImpl implements abstract accept(visitor: Visitor): R; andThen(fn: (value: ResultType, ...restArgs: RestArgs) => Return): (input: unknown, ...restArgs: RestArgs) => Return; assert(input: unknown): asserts input is ResultType; + get autoCast(): this; + get autoCastAll(): this; protected autoCaster?(this: BaseTypeImpl, value: unknown): unknown; abstract readonly basicType: BasicType | 'mixed'; get check(): (this: void, input: unknown) => ResultType; protected combineConfig(oldConfig: TypeConfig, newConfig: TypeConfig): TypeConfig; construct(input: unknown): ResultType; // (undocumented) - protected createAutoCastAllType(): Type; + protected createAutoCastAllType(): this; protected createResult(input: unknown, result: unknown, validatorResult: ValidationResult): Result; - protected readonly customValidators: ReadonlyArray>; readonly enumerableLiteralDomain?: Iterable; extendWith(factory: (type: this) => E): this & E; get is(): TypeguardFor; @@ -104,19 +96,17 @@ export function booleanAutoCaster(input: unknown): boolean | typeof autoCastFail export type Branded = T extends WithBrands ? WithBrands : WithBrands; // @public -export const brands: unique symbol; - -// @public -export function createType>(impl: Impl, override?: Partial | 'typeValidator' | 'typeParser' | 'customValidators', PropertyDescriptor>>): TypeImpl; +export function createType>(impl: Impl, override?: Partial | 'typeValidator' | 'typeParser', PropertyDescriptor>>): TypeImpl; // @public export type CustomMessage = undefined | string | ((got: string, input: T, explanation: E) => string); // @public -export type DeepUnbranded = T extends readonly [any, ...any[]] | readonly [] ? UnbrandValues> : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends Record ? UnbrandValues> : Unbranded; - -// @public -export const designType: unique symbol; +export type DeepUnbranded = T extends ReadonlyArray ? { + [P in keyof T & number]: DeepUnbranded; +} : T extends Record ? Omit<{ + [P in keyof T]: DeepUnbranded; +}, typeof brands> : Unbranded; // @public export interface Failure { @@ -131,8 +121,8 @@ export interface Failure { // @public export type FailureDetails = ValidationDetails & MessageDetails; -// @public -export type FullType = TypeImpl, Simplify>>>>; +// @public (undocumented) +export type FullType = TypeImpl>>>; // @public (undocumented) export type int = The; @@ -141,35 +131,18 @@ export type int = The; export const int: Type, NumberTypeConfig>; // @public -export interface InterfaceMergeOptions { - name?: string | null; - omitParsers?: true; - omitValidations?: true; -} - -// @public -export interface InterfacePickOptions { - applyParser?: boolean; - name?: string | null; - omitValidations?: true; -} - -// @public -export class InterfaceType extends BaseObjectLikeTypeImpl implements TypedPropertyInformation { +export class InterfaceType extends BaseObjectLikeTypeImpl implements TypedPropertyInformation { constructor( - propsInfo: PropertiesInfo, options: InterfaceTypeOptions); + props: Props, options: InterfaceTypeOptions); accept(visitor: Visitor): R; readonly basicType: 'object'; // (undocumented) readonly isDefaultName: boolean; - readonly keys: readonly (keyof Props & keyof ResultType & string)[]; + readonly keys: readonly (keyof Props)[]; maybeStringify(value: ResultType): string; - mergeWith(...args: [type: InterfaceType] | [name: string, type: InterfaceType] | [options: InterfaceMergeOptions, type: InterfaceType]): MergeType; readonly name: string; - omit(...args: [keys: OneOrMore] | [name: string, keys: OneOrMore] | [options: InterfacePickOptions, keys: OneOrMore]): PickType>; // (undocumented) readonly options: InterfaceTypeOptions; - pick(...args: [keys: OneOrMore] | [name: string, keys: OneOrMore] | [options: InterfacePickOptions, keys: OneOrMore]): PickType; // (undocumented) readonly possibleDiscriminators: readonly PossibleDiscriminator[]; // (undocumented) @@ -179,21 +152,15 @@ export class InterfaceType; readonly typeConfig: undefined; protected typeValidator(input: unknown, options: ValidationOptions): Result; - withOptional(...args: [props: PartialProps] | [name: string, props: PartialProps] | [options: InterfaceMergeOptions, props: PartialProps]): MergeType>>>; - withRequired(...args: [props: OtherProps] | [name: string, props: OtherProps] | [options: InterfaceMergeOptions, props: OtherProps]): MergeType>>; + withOptional(...args: [props: PartialProps] | [name: string, props: PartialProps]): TypeImpl>>>>> & TypedPropertyInformation; } // @public export interface InterfaceTypeOptions { checkOnly?: boolean; name?: string; - strictMissingKeys?: boolean; -} - -// @public (undocumented) -export interface InterfaceTypeOptionsWithPartial extends InterfaceTypeOptions { - // @deprecated partial?: boolean; + strictMissingKeys?: boolean; } // @public @@ -282,10 +249,9 @@ export class LiteralType extends BaseTypeImpl = T extends Record ? Simplify : T; - -// @public -export type MergeType = TypeImpl & OtherProps>, Simplify & OtherResultType>>>; +export type MergeIntersection = T extends Record ? { + [P in keyof T]: T[P]; +} & {} : T; // @public export type MessageDetails = Partial & { @@ -358,7 +324,7 @@ export type NumberTypeConfig = { export type NumberViolation = 'min' | 'max' | 'multipleOf'; // @public -export function object(...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptionsWithPartial, props: Props]): FullType; +export function object(...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptions, props: Props]): FullType; // @public export type ObjectType = TypeImpl>; @@ -373,17 +339,14 @@ export interface ParserOptions { } // @public -export function partial(...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptions, props: Props]): PartialType; +export function partial(...args: [props: Props] | [name: string, props: Props] | [options: Omit, props: Props]): PartialType; -// @public -export type PartialType = TypeImpl, Simplify>>>>>; +// @public (undocumented) +export type PartialType = TypeImpl>>>>; // @public (undocumented) export function pattern(name: BrandName, regExp: RegExp, customMessage?: StringTypeConfig['customMessage']): Type, StringTypeConfig>; -// @public -export type PickType = TypeImpl>, Simplify>>>; - // @public export type PossibleDiscriminator = { readonly path: readonly string[]; @@ -411,7 +374,10 @@ export type Properties = Record>; // @public export type PropertiesInfo = { - [Key in keyof Props]: PropertyInfo; + [Key in keyof Props]: { + partial: boolean; + type: Props[Key]; + }; }; // @public (undocumented) @@ -421,12 +387,6 @@ export type PropertiesOfTypeTuple = Tuple extends [{ readonly props: infer A; }, ...infer Rest] ? MergeIntersection> : Properties; -// @public -export type PropertyInfo = Type> = { - optional: boolean; - type: T; -}; - // @public export function record(...args: [name: string, keyType: BaseTypeImpl, valueType: BaseTypeImpl, strict?: boolean] | [keyType: BaseTypeImpl, valueType: BaseTypeImpl, strict?: boolean]): TypeImpl, KeyType, BaseTypeImpl, ValueType>>; @@ -456,9 +416,6 @@ export { reportError_2 as reportError } // @public export type Result = Success | Failure; -// @public (undocumented) -export type SimpleAcceptVisitor = (type: SimpleType, visitor: Visitor) => R; - // @public export class SimpleType extends BaseTypeImpl { accept(visitor: Visitor): R; @@ -472,6 +429,8 @@ export class SimpleType extends BaseTypeImpl { + // Warning: (ae-forgotten-export) The symbol "SimpleAcceptVisitor" needs to be exported by the entry point index.d.ts + // // (undocumented) acceptVisitor?: SimpleAcceptVisitor; // (undocumented) @@ -486,11 +445,6 @@ export interface SimpleTypeOptions { typeConfig: BaseTypeImpl['typeConfig']; } -// @public -export type Simplify = { - [P in keyof T]: T[P]; -} & {}; - // @public export const string: Type; @@ -561,11 +515,6 @@ export type TypeOfProperties = { // @public export type Unbranded = T extends WithBrands ? Base : T; -// @public (undocumented) -export type UnbrandValues = { - [P in keyof T]: DeepUnbranded; -}; - // @public (undocumented) export const undefinedType: TypeImpl>; @@ -623,17 +572,17 @@ export type ValidationDetails = { // @public export class ValidationError extends Error implements Failure { // (undocumented) - readonly details: OneOrMore; + details: OneOrMore; static fromFailure(failure: Failure): ValidationError; // (undocumented) - readonly input: unknown; + input: unknown; // (undocumented) readonly name = "ValidationError"; // (undocumented) readonly ok = false; static try({ type, input }: Pick, fn: () => Return): Result; // (undocumented) - readonly type: BaseTypeImpl; + type: BaseTypeImpl; } // @public @@ -648,7 +597,7 @@ export interface ValidationOptions { } // @public -export type ValidationResult = undefined | boolean | string | MessageDetails | Iterable; +export type ValidationResult = boolean | string | MessageDetails | Array; // @public export type Validator = (input: ResultType, options: ValidationOptions) => ValidationResult; diff --git a/markdown/types.autocast.md b/markdown/types.autocast.md deleted file mode 100644 index da21855..0000000 --- a/markdown/types.autocast.md +++ /dev/null @@ -1,27 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [autoCast](./types.autocast.md) - -## autoCast() function - -Returns the same type, but with an auto-casting default parser installed. - -**Signature:** - -```typescript -declare function autoCast>(type: T): T; -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ---- | ----------- | -| type | T | | - -**Returns:** - -T - -## Remarks - -Each type implementation provides its own auto-cast rules. See builtin types for examples of auto-cast rules. diff --git a/markdown/types.autocastall.md b/markdown/types.autocastall.md deleted file mode 100644 index 5ea5fd2..0000000 --- a/markdown/types.autocastall.md +++ /dev/null @@ -1,27 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [autoCastAll](./types.autocastall.md) - -## autoCastAll() function - -Create a recursive autocasting version of the given type. - -**Signature:** - -```typescript -declare function autoCastAll>(type: T): T; -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ---- | ----------- | -| type | T | | - -**Returns:** - -T - -## Remarks - -This will replace any parser in the nested structure with the appropriate autocaster when applicable. diff --git a/markdown/types.autocastfailure.md b/markdown/types.autocastfailure.md deleted file mode 100644 index f114726..0000000 --- a/markdown/types.autocastfailure.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [autoCastFailure](./types.autocastfailure.md) - -## autoCastFailure variable - -Returned by an autocaster to indicate that it is not able to auto-cast the given input. - -**Signature:** - -```typescript -autoCastFailure: unique symbol -``` diff --git a/markdown/types.baseobjectliketypeimpl.and.md b/markdown/types.baseobjectliketypeimpl.and.md index e187a48..5e2794c 100644 --- a/markdown/types.baseobjectliketypeimpl.and.md +++ b/markdown/types.baseobjectliketypeimpl.and.md @@ -20,7 +20,7 @@ and>(_other: Other): ObjectType<[MergeIntersection](./types.mergeintersection.md)<ResultType & Other\[typeof [designType](./types.designtype.md)\]>> & [TypedPropertyInformation](./types.typedpropertyinformation.md)<this\['props'\] & Other\['props'\]> +[ObjectType](./types.objecttype.md)<[MergeIntersection](./types.mergeintersection.md)<ResultType & Other\[typeof designType\]>> & [TypedPropertyInformation](./types.typedpropertyinformation.md)<this\['props'\] & Other\['props'\]> ## Remarks diff --git a/markdown/types.baseobjectliketypeimpl.md b/markdown/types.baseobjectliketypeimpl.md index ed02322..2ff4876 100644 --- a/markdown/types.baseobjectliketypeimpl.md +++ b/markdown/types.baseobjectliketypeimpl.md @@ -20,13 +20,13 @@ Object-like types need to provide more information to be able to correctly compo ## Properties -| Property | Modifiers | Type | Description | -| ---------------------------------------------------------------------------------- | --------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------- | -| [isDefaultName](./types.baseobjectliketypeimpl.isdefaultname.md) |

abstract

readonly

| boolean | | -| [possibleDiscriminators](./types.baseobjectliketypeimpl.possiblediscriminators.md) |

abstract

readonly

| readonly [PossibleDiscriminator](./types.possiblediscriminator.md)\[\] | | -| [props](./types.baseobjectliketypeimpl.props.md) |

abstract

readonly

| [Properties](./types.properties.md) | | -| [propsArray](./types.baseobjectliketypeimpl.propsarray.md) |

protected

readonly

| ReadonlyArray<\[string, [PropertyInfo](./types.propertyinfo.md)\]> | Array of props tuples (Object.entries(this.prop)). | -| [propsInfo](./types.baseobjectliketypeimpl.propsinfo.md) |

abstract

readonly

| [PropertiesInfo](./types.propertiesinfo.md) | | +| Property | Modifiers | Type | Description | +| ---------------------------------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------- | +| [isDefaultName](./types.baseobjectliketypeimpl.isdefaultname.md) |

abstract

readonly

| boolean | | +| [possibleDiscriminators](./types.baseobjectliketypeimpl.possiblediscriminators.md) |

abstract

readonly

| readonly [PossibleDiscriminator](./types.possiblediscriminator.md)\[\] | | +| [props](./types.baseobjectliketypeimpl.props.md) |

abstract

readonly

| [Properties](./types.properties.md) | | +| [propsArray](./types.baseobjectliketypeimpl.propsarray.md) |

protected

readonly

| ReadonlyArray<\[string, [Type](./types.type.md)<unknown>\]> | Array of props tuples (Object.entries(this.prop)). | +| [propsInfo](./types.baseobjectliketypeimpl.propsinfo.md) |

abstract

readonly

| [PropertiesInfo](./types.propertiesinfo.md) | | ## Methods diff --git a/markdown/types.baseobjectliketypeimpl.propsarray.md b/markdown/types.baseobjectliketypeimpl.propsarray.md index 03a1719..bab8a6a 100644 --- a/markdown/types.baseobjectliketypeimpl.propsarray.md +++ b/markdown/types.baseobjectliketypeimpl.propsarray.md @@ -9,5 +9,5 @@ Array of props tuples (`Object.entries(this.prop)`). **Signature:** ```typescript -protected get propsArray(): ReadonlyArray<[string, PropertyInfo]>; +protected get propsArray(): ReadonlyArray<[string, Type]>; ``` diff --git a/markdown/types.basetypeimpl.createautocastalltype.md b/markdown/types.basetypeimpl.createautocastalltype.md index dc85269..ff6c463 100644 --- a/markdown/types.basetypeimpl.createautocastalltype.md +++ b/markdown/types.basetypeimpl.createautocastalltype.md @@ -7,9 +7,9 @@ **Signature:** ```typescript -protected createAutoCastAllType(): Type; +protected createAutoCastAllType(): this; ``` **Returns:** -[Type](./types.type.md)<ResultType> +this diff --git a/markdown/types.basetypeimpl.customvalidators.md b/markdown/types.basetypeimpl.customvalidators.md deleted file mode 100644 index 6682b87..0000000 --- a/markdown/types.basetypeimpl.customvalidators.md +++ /dev/null @@ -1,17 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [BaseTypeImpl](./types.basetypeimpl.md) > [customValidators](./types.basetypeimpl.customvalidators.md) - -## BaseTypeImpl.customValidators property - -Additional custom validation added using [withValidation](./types.basetypeimpl.withvalidation.md) or [withConstraint](./types.basetypeimpl.withconstraint.md). - -**Signature:** - -```typescript -protected readonly customValidators: ReadonlyArray>; -``` - -## Remarks - -It says `Validator` here, but it should only contain closures with `Validator` parameters. However, that would mean that this type is no longer assignable to `Type` which is technically correct, but very inconvenient. We want to be able to write functions that ask for a type that validates anything, we don't care what. If we are not able to use the type `Type` in those cases, then we are left with `Type` which leads to `any`-contamination of our consumer code. diff --git a/markdown/types.basetypeimpl.md b/markdown/types.basetypeimpl.md index 3bbc782..91bb59a 100644 --- a/markdown/types.basetypeimpl.md +++ b/markdown/types.basetypeimpl.md @@ -20,15 +20,16 @@ All type-implementations must extend this base class. Use [createType()](./types ## Properties -| Property | Modifiers | Type | Description | -| --------------------------------------------------------------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [basicType](./types.basetypeimpl.basictype.md) |

abstract

readonly

| [BasicType](./types.basictype.md) \| 'mixed' | The kind of values this type validates. | -| [check](./types.basetypeimpl.check.md) | readonly | (this: void, input: unknown) => ResultType | Asserts that a value conforms to this Type and returns the input as is, if it does. | -| [customValidators](./types.basetypeimpl.customvalidators.md) |

protected

readonly

| ReadonlyArray<[Validator](./types.validator.md)<unknown>> | Additional custom validation added using [withValidation](./types.basetypeimpl.withvalidation.md) or [withConstraint](./types.basetypeimpl.withconstraint.md). | -| [enumerableLiteralDomain?](./types.basetypeimpl.enumerableliteraldomain.md) | readonly | Iterable<[LiteralValue](./types.literalvalue.md)> | _(Optional)_ The set of valid literals if enumerable. | -| [is](./types.basetypeimpl.is.md) | readonly | [TypeguardFor](./types.typeguardfor.md)<ResultType> | A type guard for this Type. | -| [name](./types.basetypeimpl.name.md) |

abstract

readonly

| string | The name of the Type. | -| [typeConfig](./types.basetypeimpl.typeconfig.md) |

abstract

readonly

| TypeConfig | Extra information that is made available by this Type for runtime analysis. | +| Property | Modifiers | Type | Description | +| --------------------------------------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| [autoCast](./types.basetypeimpl.autocast.md) | readonly | this | The same type, but with an auto-casting default parser installed. | +| [autoCastAll](./types.basetypeimpl.autocastall.md) | readonly | this | Create a recursive autocasting version of the current type. | +| [basicType](./types.basetypeimpl.basictype.md) |

abstract

readonly

| [BasicType](./types.basictype.md) \| 'mixed' | The kind of values this type validates. | +| [check](./types.basetypeimpl.check.md) | readonly | (this: void, input: unknown) => ResultType | Asserts that a value conforms to this Type and returns the input as is, if it does. | +| [enumerableLiteralDomain?](./types.basetypeimpl.enumerableliteraldomain.md) | readonly | Iterable<[LiteralValue](./types.literalvalue.md)> | _(Optional)_ The set of valid literals if enumerable. | +| [is](./types.basetypeimpl.is.md) | readonly | [TypeguardFor](./types.typeguardfor.md)<ResultType> | A type guard for this Type. | +| [name](./types.basetypeimpl.name.md) |

abstract

readonly

| string | The name of the Type. | +| [typeConfig](./types.basetypeimpl.typeconfig.md) |

abstract

readonly

| TypeConfig | Extra information that is made available by this Type for runtime analysis. | ## Methods @@ -52,7 +53,7 @@ All type-implementations must extend this base class. Use [createType()](./types | [validate(input, options)](./types.basetypeimpl.validate.md) | | Validates that a value conforms to this type, and returns a result indicating success or failure (does not throw). | | [withBrand(name)](./types.basetypeimpl.withbrand.md) | | Create a new instance of this Type with the given name. | | [withConfig(name, newConfig)](./types.basetypeimpl.withconfig.md) | | Create a new instance of this Type with the additional type-specific config, such as min/max values. | -| [withConstraint(name, constraint)](./types.basetypeimpl.withconstraint.md) | | Create a new type based on the current type and use the given constraint function as validation. | +| [withConstraint(name, constraint)](./types.basetypeimpl.withconstraint.md) | | Create a new type use the given constraint function to restrict the current type. | | [withName(name)](./types.basetypeimpl.withname.md) | | Create a new instance of this Type with the given name. | | [withParser(args)](./types.basetypeimpl.withparser.md) | | Define a new type with the same specs, but with the given parser and an optional new name. | | [withValidation(validation)](./types.basetypeimpl.withvalidation.md) | | Clone the type with the added validation. | diff --git a/markdown/types.basetypeimpl.withconstraint.md b/markdown/types.basetypeimpl.withconstraint.md index 68d5bf5..8c1cc20 100644 --- a/markdown/types.basetypeimpl.withconstraint.md +++ b/markdown/types.basetypeimpl.withconstraint.md @@ -4,7 +4,7 @@ ## BaseTypeImpl.withConstraint() method -Create a new type based on the current type and use the given constraint function as validation. +Create a new type use the given constraint function to restrict the current type. **Signature:** diff --git a/markdown/types.booleanautocaster.md b/markdown/types.booleanautocaster.md index 69c13f3..5c9da3f 100644 --- a/markdown/types.booleanautocaster.md +++ b/markdown/types.booleanautocaster.md @@ -18,4 +18,4 @@ declare function booleanAutoCaster(input: unknown): boolean | typeof autoCastFai **Returns:** -boolean \| typeof [autoCastFailure](./types.autocastfailure.md) +boolean \| typeof autoCastFailure diff --git a/markdown/types.brands.md b/markdown/types.brands.md deleted file mode 100644 index 02e3739..0000000 --- a/markdown/types.brands.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [brands](./types.brands.md) - -## brands variable - -The symbol that gives access to the (design-time-only) brands of a Type. - -**Signature:** - -```typescript -brands: unique symbol -``` diff --git a/markdown/types.createtype.md b/markdown/types.createtype.md index f3f3ab2..6e42f4c 100644 --- a/markdown/types.createtype.md +++ b/markdown/types.createtype.md @@ -11,16 +11,16 @@ Create a Type from the given type-implementation. ```typescript declare function createType>( impl: Impl, - override?: Partial | 'typeValidator' | 'typeParser' | 'customValidators', PropertyDescriptor>>, + override?: Partial | 'typeValidator' | 'typeParser', PropertyDescriptor>>, ): TypeImpl; ``` ## Parameters -| Parameter | Type | Description | -| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | -| impl | Impl | the type-implementation | -| override | Partial<Record<keyof [BaseTypeImpl](./types.basetypeimpl.md)<any, any> \| 'typeValidator' \| 'typeParser' \| 'customValidators', PropertyDescriptor>> | _(Optional)_ override certain settings of the created type | +| Parameter | Type | Description | +| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | +| impl | Impl | the type-implementation | +| override | Partial<Record<keyof [BaseTypeImpl](./types.basetypeimpl.md)<any, any> \| 'typeValidator' \| 'typeParser', PropertyDescriptor>> | _(Optional)_ override certain settings of the created type | **Returns:** diff --git a/markdown/types.deepunbranded.md b/markdown/types.deepunbranded.md index bd663ad..571c3b8 100644 --- a/markdown/types.deepunbranded.md +++ b/markdown/types.deepunbranded.md @@ -9,15 +9,18 @@ Unbrand a given type (recursive). **Signature:** ```typescript -type DeepUnbranded = T extends readonly [any, ...any[]] | readonly [] - ? UnbrandValues> - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> +type DeepUnbranded = T extends ReadonlyArray + ? { + [P in keyof T & number]: DeepUnbranded; + } : T extends Record - ? UnbrandValues> + ? Omit< + { + [P in keyof T]: DeepUnbranded; + }, + typeof brands + > : Unbranded; ``` -**References:** [UnbrandValues](./types.unbrandvalues.md), [Unbranded](./types.unbranded.md), [DeepUnbranded](./types.deepunbranded.md) +**References:** [DeepUnbranded](./types.deepunbranded.md), [Unbranded](./types.unbranded.md) diff --git a/markdown/types.designtype.md b/markdown/types.designtype.md deleted file mode 100644 index bebca4c..0000000 --- a/markdown/types.designtype.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [designType](./types.designtype.md) - -## designType variable - -The symbol that gives access to the (design-time-only) associated TypeScript type of a Type. - -**Signature:** - -```typescript -designType: unique symbol -``` diff --git a/markdown/types.fulltype.md b/markdown/types.fulltype.md index 30b4a35..6cd4c26 100644 --- a/markdown/types.fulltype.md +++ b/markdown/types.fulltype.md @@ -4,12 +4,10 @@ ## FullType type -Result of the [object()](./types.object.md) function. - **Signature:** ```typescript -type FullType = TypeImpl, Simplify>>>>; +type FullType = TypeImpl>>>; ``` -**References:** [Properties](./types.properties.md), [TypeImpl](./types.typeimpl.md), [InterfaceType](./types.interfacetype.md), [Simplify](./types.simplify.md), [TypeOfProperties](./types.typeofproperties.md), [Writable](./types.writable.md) +**References:** [Properties](./types.properties.md), [TypeImpl](./types.typeimpl.md), [InterfaceType](./types.interfacetype.md), [TypeOfProperties](./types.typeofproperties.md), [Writable](./types.writable.md) diff --git a/markdown/types.interfacemergeoptions.md b/markdown/types.interfacemergeoptions.md deleted file mode 100644 index ce5d916..0000000 --- a/markdown/types.interfacemergeoptions.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceMergeOptions](./types.interfacemergeoptions.md) - -## InterfaceMergeOptions interface - -Options for [InterfaceType.withOptional()](./types.interfacetype.withoptional.md), [InterfaceType.withRequired()](./types.interfacetype.withrequired.md) and [InterfaceType.mergeWith()](./types.interfacetype.mergewith.md). - -**Signature:** - -```typescript -interface InterfaceMergeOptions -``` - -## Properties - -| Property | Modifiers | Type | Description | -| -------------------------------------------------------------------- | --------- | -------------- | ---------------------------------------------------------------------------------------------------------------- | -| [name?](./types.interfacemergeoptions.name.md) | | string \| null | _(Optional)_ The optional name for the new type, or null to force a generated TypeScript-like name. | -| [omitParsers?](./types.interfacemergeoptions.omitparsers.md) | | true | _(Optional)_ Suppress the error about existing custom parsers on one of the types that is being merged. | -| [omitValidations?](./types.interfacemergeoptions.omitvalidations.md) | | true | _(Optional)_ When set, do not apply the custom validations from the base types onto the new merged type. | diff --git a/markdown/types.interfacemergeoptions.name.md b/markdown/types.interfacemergeoptions.name.md deleted file mode 100644 index c6d44a1..0000000 --- a/markdown/types.interfacemergeoptions.name.md +++ /dev/null @@ -1,19 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceMergeOptions](./types.interfacemergeoptions.md) > [name](./types.interfacemergeoptions.name.md) - -## InterfaceMergeOptions.name property - -The optional name for the new type, or `null` to force a generated TypeScript-like name. - -**Signature:** - -```typescript -name?: string | null; -``` - -## Remarks - -When omitted, it will follow the name of original type (on the left). It will either use the custom name of that type or generate a new default TypeScript-like name if the type did not have a custom name. - -Use this `name` setting with a `string` to provide a new custom name or use `null` to force a generated TypeScript-like name, even if the original type has a custom name. diff --git a/markdown/types.interfacemergeoptions.omitparsers.md b/markdown/types.interfacemergeoptions.omitparsers.md deleted file mode 100644 index e152148..0000000 --- a/markdown/types.interfacemergeoptions.omitparsers.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceMergeOptions](./types.interfacemergeoptions.md) > [omitParsers](./types.interfacemergeoptions.omitparsers.md) - -## InterfaceMergeOptions.omitParsers property - -Suppress the error about existing custom parsers on one of the types that is being merged. - -**Signature:** - -```typescript -omitParsers?: true; -``` - -## Remarks - -Parsers are not reused when merging multiple interface types using [withOptional](./types.interfacetype.withoptional.md), [withRequired](./types.interfacetype.withrequired.md) and [mergeWith](./types.interfacetype.mergewith.md). When a custom parser is encountered by Skunk Team types, an Error will be thrown. Use this option to ignore the parsers and continue with the merge. - -This is to ensure that custom parser are never accidentally lost by adding additional properties to an existing type. - -Alternatively, it is always possible to use an [intersection()](./types.intersection.md) instead. diff --git a/markdown/types.interfacemergeoptions.omitvalidations.md b/markdown/types.interfacemergeoptions.omitvalidations.md deleted file mode 100644 index a7d0f3a..0000000 --- a/markdown/types.interfacemergeoptions.omitvalidations.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceMergeOptions](./types.interfacemergeoptions.md) > [omitValidations](./types.interfacemergeoptions.omitvalidations.md) - -## InterfaceMergeOptions.omitValidations property - -When set, do not apply the custom validations from the base types onto the new merged type. - -**Signature:** - -```typescript -omitValidations?: true; -``` - -## Remarks - -By default, custom validations (i.e. validations that are added to a type using [withValidation](./types.basetypeimpl.withvalidation.md) or [withConstraint](./types.basetypeimpl.withconstraint.md)) are reused when merging multiple interface types using [withOptional](./types.interfacetype.withoptional.md), [withRequired](./types.interfacetype.withrequired.md) and [mergeWith](./types.interfacetype.mergewith.md). Use this option to omit all custom validations in the resulting merged type. - -Note that reuse of custom validations only works when no properties overlap between the types that are being merged. As long as the properties don't overlap we can be sure that the merged type is assignable to each of the original types (`A & B` is assignable to both `A` and `B`). Therefore, the validations are still safe to run, even though the type has been extended with additional properties. - -When overlap is detected in the property-names of the types and any custom validation is encountered by Skunk Team types, an Error will be thrown. Use this option to ignore the custom validations and continue with the merge. - -Alternatively, it is always possible to use an [intersection()](./types.intersection.md) instead. diff --git a/markdown/types.interfacepickoptions.applyparser.md b/markdown/types.interfacepickoptions.applyparser.md deleted file mode 100644 index 3deecdb..0000000 --- a/markdown/types.interfacepickoptions.applyparser.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfacePickOptions](./types.interfacepickoptions.md) > [applyParser](./types.interfacepickoptions.applyparser.md) - -## InterfacePickOptions.applyParser property - -Choose whether to apply the custom parser from the base type onto the newly "picked type" or not. - -**Signature:** - -```typescript -applyParser?: boolean; -``` - -## Remarks - -By default, custom parsers (i.e. parsers that are added to a type using [BaseTypeImpl.withParser()](./types.basetypeimpl.withparser.md) or [autoCast()](./types.autocast.md)) are not reused when a new type is created using [InterfaceType.pick()](./types.interfacetype.pick.md) and [InterfaceType.omit()](./types.interfacetype.omit.md). - -However, it is possible to reuse a parser that is set on the base type. Parsers have a single input of type `unknown` and may produce anything (also with type `unknown`). The result of a parser will always be validated afterwards by the type it is applied to. Technically, any parser is applicable to any type, but it might not make sense to do so. Therefore, you can choose to apply it or not with this option. - -If a custom parser is found on the base type, then this options is mandatory. diff --git a/markdown/types.interfacepickoptions.md b/markdown/types.interfacepickoptions.md deleted file mode 100644 index 09d7acd..0000000 --- a/markdown/types.interfacepickoptions.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfacePickOptions](./types.interfacepickoptions.md) - -## InterfacePickOptions interface - -Options for [InterfaceType.pick()](./types.interfacetype.pick.md) and [InterfaceType.omit()](./types.interfacetype.omit.md). - -**Signature:** - -```typescript -interface InterfacePickOptions -``` - -## Properties - -| Property | Modifiers | Type | Description | -| ------------------------------------------------------------------- | --------- | -------------- | ---------------------------------------------------------------------------------------------------------------- | -| [applyParser?](./types.interfacepickoptions.applyparser.md) | | boolean | _(Optional)_ Choose whether to apply the custom parser from the base type onto the newly "picked type" or not. | -| [name?](./types.interfacepickoptions.name.md) | | string \| null | _(Optional)_ The optional name for the new type, or null to force a generated TypeScript-like name. | -| [omitValidations?](./types.interfacepickoptions.omitvalidations.md) | | true | _(Optional)_ Suppress the error about existing custom validations on the base type. | diff --git a/markdown/types.interfacepickoptions.name.md b/markdown/types.interfacepickoptions.name.md deleted file mode 100644 index d38e739..0000000 --- a/markdown/types.interfacepickoptions.name.md +++ /dev/null @@ -1,19 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfacePickOptions](./types.interfacepickoptions.md) > [name](./types.interfacepickoptions.name.md) - -## InterfacePickOptions.name property - -The optional name for the new type, or `null` to force a generated TypeScript-like name. - -**Signature:** - -```typescript -name?: string | null; -``` - -## Remarks - -When omitted, it will follow the name of original type (on the left). It will either use the custom name of that type or generate a new default TypeScript-like name if the type did not have a custom name. - -Use this `name` setting with a `string` to provide a new custom name or use `null` to force a generated TypeScript-like name, even if the original type has a custom name. diff --git a/markdown/types.interfacepickoptions.omitvalidations.md b/markdown/types.interfacepickoptions.omitvalidations.md deleted file mode 100644 index 9721460..0000000 --- a/markdown/types.interfacepickoptions.omitvalidations.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfacePickOptions](./types.interfacepickoptions.md) > [omitValidations](./types.interfacepickoptions.omitvalidations.md) - -## InterfacePickOptions.omitValidations property - -Suppress the error about existing custom validations on the base type. - -**Signature:** - -```typescript -omitValidations?: true; -``` - -## Remarks - -Validations are not reused when picking or omitting properties from a base type. This is because validations work on the original base type. The new type, with some properties omitted, is not assignable to the original type. Therefore, we cannot reliably call the validations with instances of the new type. - -When a custom validation is encountered by Skunk Team types, an Error will be thrown. Use this option to ignore the validations and continue with the pick or omit operation. - -This is to ensure that custom validations are never accidentally lost. diff --git a/markdown/types.interfacetype._constructor_.md b/markdown/types.interfacetype._constructor_.md index 7ba026c..d06f041 100644 --- a/markdown/types.interfacetype._constructor_.md +++ b/markdown/types.interfacetype._constructor_.md @@ -10,12 +10,12 @@ Constructs a new instance of the `InterfaceType` class ```typescript constructor( - propsInfo: PropertiesInfo, options: InterfaceTypeOptions); + props: Props, options: InterfaceTypeOptions); ``` ## Parameters -| Parameter | Type | Description | -| --------- | ---------------------------------------------------------------- | ----------- | -| propsInfo | [PropertiesInfo](./types.propertiesinfo.md)<Props> | | -| options | [InterfaceTypeOptions](./types.interfacetypeoptions.md) | | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------- | ----------- | +| props | Props | | +| options | [InterfaceTypeOptions](./types.interfacetypeoptions.md) | | diff --git a/markdown/types.interfacetype.keys.md b/markdown/types.interfacetype.keys.md index bb0f39b..569776e 100644 --- a/markdown/types.interfacetype.keys.md +++ b/markdown/types.interfacetype.keys.md @@ -9,5 +9,5 @@ The keys (property-names) for this object-like type. **Signature:** ```typescript -readonly keys: readonly (keyof Props & keyof ResultType & string)[]; +readonly keys: readonly (keyof Props)[]; ``` diff --git a/markdown/types.interfacetype.md b/markdown/types.interfacetype.md index a36e3af..97a73db 100644 --- a/markdown/types.interfacetype.md +++ b/markdown/types.interfacetype.md @@ -9,7 +9,7 @@ The implementation behind types created with [object()](./types.object.md) and [ **Signature:** ```typescript -declare class InterfaceType extends BaseObjectLikeTypeImpl implements TypedPropertyInformation +declare class InterfaceType extends BaseObjectLikeTypeImpl implements TypedPropertyInformation ``` **Extends:** [BaseObjectLikeTypeImpl](./types.baseobjectliketypeimpl.md)<ResultType> @@ -18,9 +18,9 @@ declare class InterfaceTypeInterfaceType class | +| Constructor | Modifiers | Description | +| ----------------------------------------------------------------------- | --------- | ----------------------------------------------------------------- | +| [(constructor)(props, options)](./types.interfacetype._constructor_.md) | | Constructs a new instance of the InterfaceType class | ## Properties @@ -28,7 +28,7 @@ declare class InterfaceTypereadonly | 'object' | The kind of values this type validates. | | [isDefaultName](./types.interfacetype.isdefaultname.md) | readonly | boolean | | -| [keys](./types.interfacetype.keys.md) | readonly | readonly (keyof Props & keyof ResultType & string)\[\] | The keys (property-names) for this object-like type. | +| [keys](./types.interfacetype.keys.md) | readonly | readonly (keyof Props)\[\] | The keys (property-names) for this object-like type. | | [name](./types.interfacetype.name.md) | readonly | string | The name of the Type. | | [options](./types.interfacetype.options.md) | readonly | [InterfaceTypeOptions](./types.interfacetypeoptions.md) | | | [possibleDiscriminators](./types.interfacetype.possiblediscriminators.md) | readonly | readonly [PossibleDiscriminator](./types.possiblediscriminator.md)\[\] | | @@ -42,10 +42,6 @@ declare class InterfaceTypeJSON.stringify. | -| [mergeWith(args)](./types.interfacetype.mergewith.md) | | Create a new type by merging all properties of the given type into the properties of this type. | -| [omit(args)](./types.interfacetype.omit.md) | | Create a new type that consists of all properties of the base type, except those mentioned, similar to the builtin Omit type. | -| [pick(args)](./types.interfacetype.pick.md) | | Create a new type that consists only of the mentioned properties similar to the builtin Pick type. | | [toPartial(name)](./types.interfacetype.topartial.md) | | Clone this type with all properties marked optional. | | [typeValidator(input, options)](./types.interfacetype.typevalidator.md) | protected | The actual validation-logic. | | [withOptional(args)](./types.interfacetype.withoptional.md) | | Create a type with all properties of the current type, plus the given optional properties. | -| [withRequired(args)](./types.interfacetype.withrequired.md) | | Create a type with all properties of the current type, plus the given additional required properties. | diff --git a/markdown/types.interfacetype.mergewith.md b/markdown/types.interfacetype.mergewith.md deleted file mode 100644 index e533bdd..0000000 --- a/markdown/types.interfacetype.mergewith.md +++ /dev/null @@ -1,27 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceType](./types.interfacetype.md) > [mergeWith](./types.interfacetype.mergewith.md) - -## InterfaceType.mergeWith() method - -Create a new type by merging all properties of the given type into the properties of this type. - -**Signature:** - -```typescript -mergeWith(...args: [type: InterfaceType] | [name: string, type: InterfaceType] | [options: InterfaceMergeOptions, type: InterfaceType]): MergeType; -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| args | \[type: [InterfaceType](./types.interfacetype.md)<OtherProps, OtherType>\] \| \[name: string, type: [InterfaceType](./types.interfacetype.md)<OtherProps, OtherType>\] \| \[options: [InterfaceMergeOptions](./types.interfacemergeoptions.md), type: [InterfaceType](./types.interfacetype.md)<OtherProps, OtherType>\] | | - -**Returns:** - -[MergeType](./types.mergetype.md)<Props, ResultType, OtherProps, OtherType> - -## Remarks - -Keys of the given (right hand side) type override keys of this type (left hand side). Any options such as `strictMissingKeys` and custom names are inherited from the left hand side type, but custom parsers and validators are dropped. diff --git a/markdown/types.interfacetype.omit.md b/markdown/types.interfacetype.omit.md deleted file mode 100644 index 8dcd304..0000000 --- a/markdown/types.interfacetype.omit.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceType](./types.interfacetype.md) > [omit](./types.interfacetype.omit.md) - -## InterfaceType.omit() method - -Create a new type that consists of all properties of the base type, except those mentioned, similar to the builtin `Omit` type. - -**Signature:** - -```typescript -omit(...args: [keys: OneOrMore] | [name: string, keys: OneOrMore] | [options: InterfacePickOptions, keys: OneOrMore]): PickType>; -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | -| args | \[keys: [OneOrMore](./types.oneormore.md)<Key>\] \| \[name: string, keys: [OneOrMore](./types.oneormore.md)<Key>\] \| \[options: [InterfacePickOptions](./types.interfacepickoptions.md), keys: [OneOrMore](./types.oneormore.md)<Key>\] | | - -**Returns:** - -[PickType](./types.picktype.md)<Props, ResultType, Exclude<keyof Props & keyof ResultType & string, Key>> diff --git a/markdown/types.interfacetype.pick.md b/markdown/types.interfacetype.pick.md deleted file mode 100644 index 4aabca0..0000000 --- a/markdown/types.interfacetype.pick.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceType](./types.interfacetype.md) > [pick](./types.interfacetype.pick.md) - -## InterfaceType.pick() method - -Create a new type that consists only of the mentioned properties similar to the builtin `Pick` type. - -**Signature:** - -```typescript -pick(...args: [keys: OneOrMore] | [name: string, keys: OneOrMore] | [options: InterfacePickOptions, keys: OneOrMore]): PickType; -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | -| args | \[keys: [OneOrMore](./types.oneormore.md)<Key>\] \| \[name: string, keys: [OneOrMore](./types.oneormore.md)<Key>\] \| \[options: [InterfacePickOptions](./types.interfacepickoptions.md), keys: [OneOrMore](./types.oneormore.md)<Key>\] | | - -**Returns:** - -[PickType](./types.picktype.md)<Props, ResultType, Key> diff --git a/markdown/types.interfacetype.withoptional.md b/markdown/types.interfacetype.withoptional.md index 0ef93ba..e627f3d 100644 --- a/markdown/types.interfacetype.withoptional.md +++ b/markdown/types.interfacetype.withoptional.md @@ -9,21 +9,15 @@ Create a type with all properties of the current type, plus the given optional p **Signature:** ```typescript -withOptional(...args: [props: PartialProps] | [name: string, props: PartialProps] | [options: InterfaceMergeOptions, props: PartialProps]): MergeType>>>; +withOptional(...args: [props: PartialProps] | [name: string, props: PartialProps]): TypeImpl>>>>> & TypedPropertyInformation; ``` ## Parameters -| Parameter | Type | Description | -| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| args | \[props: PartialProps\] \| \[name: string, props: PartialProps\] \| \[options: [InterfaceMergeOptions](./types.interfacemergeoptions.md), props: PartialProps\] | | +| Parameter | Type | Description | +| --------- | ---------------------------------------------------------------- | ----------- | +| args | \[props: PartialProps\] \| \[name: string, props: PartialProps\] | | **Returns:** -[MergeType](./types.mergetype.md)<Props, ResultType, PartialProps, Partial<[TypeOfProperties](./types.typeofproperties.md)<[Writable](./types.writable.md)<PartialProps>>>> - -## Remarks - -Note that any property that conflicts with an existing property is overwritten, so this can also be used to selectively mark certain properties as optional or change their type. - -Any options such as `strictMissingKeys` and custom names (unless provided in this call) will be inherited by this new type, but custom parsers and validators are dropped. +[TypeImpl](./types.typeimpl.md)<[BaseObjectLikeTypeImpl](./types.baseobjectliketypeimpl.md)<[MergeIntersection](./types.mergeintersection.md)<ResultType & Partial<[TypeOfProperties](./types.typeofproperties.md)<[Writable](./types.writable.md)<PartialProps>>>>>> & [TypedPropertyInformation](./types.typedpropertyinformation.md)<Props & PartialProps> diff --git a/markdown/types.interfacetype.withrequired.md b/markdown/types.interfacetype.withrequired.md deleted file mode 100644 index 3726d04..0000000 --- a/markdown/types.interfacetype.withrequired.md +++ /dev/null @@ -1,29 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceType](./types.interfacetype.md) > [withRequired](./types.interfacetype.withrequired.md) - -## InterfaceType.withRequired() method - -Create a type with all properties of the current type, plus the given additional required properties. - -**Signature:** - -```typescript -withRequired(...args: [props: OtherProps] | [name: string, props: OtherProps] | [options: InterfaceMergeOptions, props: OtherProps]): MergeType>>; -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -| args | \[props: OtherProps\] \| \[name: string, props: OtherProps\] \| \[options: [InterfaceMergeOptions](./types.interfacemergeoptions.md), props: OtherProps\] | | - -**Returns:** - -[MergeType](./types.mergetype.md)<Props, ResultType, OtherProps, [TypeOfProperties](./types.typeofproperties.md)<[Writable](./types.writable.md)<OtherProps>>> - -## Remarks - -Note that any property that conflicts with an existing property is overwritten, so this can also be used to selectively mark certain properties as required or change their type. - -Any options such as `strictMissingKeys` and custom names (unless provided in this call) will be inherited by this new type, but custom parsers and validators are dropped. diff --git a/markdown/types.interfacetypeoptions.md b/markdown/types.interfacetypeoptions.md index 1b2ca35..86f8152 100644 --- a/markdown/types.interfacetypeoptions.md +++ b/markdown/types.interfacetypeoptions.md @@ -18,4 +18,5 @@ interface InterfaceTypeOptions | ----------------------------------------------------------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- | | [checkOnly?](./types.interfacetypeoptions.checkonly.md) | | boolean | _(Optional)_ Force this type (including all nested property-types recursively) to be validated in 'check' mode. | | [name?](./types.interfacetypeoptions.name.md) | | string | _(Optional)_ The optional name for the type, uses a default TypeScript-like name if no name is given. | +| [partial?](./types.interfacetypeoptions.partial.md) | | boolean | _(Optional)_ Mark all properties as optional in this type. | | [strictMissingKeys?](./types.interfacetypeoptions.strictmissingkeys.md) | | boolean | _(Optional)_ Discriminate between missing keys and undefined values. Is off by default because that is what TypeScript does. | diff --git a/markdown/types.interfacetypeoptionswithpartial.md b/markdown/types.interfacetypeoptionswithpartial.md deleted file mode 100644 index e29a62a..0000000 --- a/markdown/types.interfacetypeoptionswithpartial.md +++ /dev/null @@ -1,19 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceTypeOptionsWithPartial](./types.interfacetypeoptionswithpartial.md) - -## InterfaceTypeOptionsWithPartial interface - -**Signature:** - -```typescript -interface InterfaceTypeOptionsWithPartial extends InterfaceTypeOptions -``` - -**Extends:** [InterfaceTypeOptions](./types.interfacetypeoptions.md) - -## Properties - -| Property | Modifiers | Type | Description | -| -------------------------------------------------------------- | --------- | ------- | ---------------------------------------------------------- | -| [partial?](./types.interfacetypeoptionswithpartial.partial.md) | | boolean | _(Optional)_ Mark all properties as optional in this type. | diff --git a/markdown/types.interfacetypeoptionswithpartial.partial.md b/markdown/types.interfacetypeoptionswithpartial.partial.md deleted file mode 100644 index 8628269..0000000 --- a/markdown/types.interfacetypeoptionswithpartial.partial.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [InterfaceTypeOptionsWithPartial](./types.interfacetypeoptionswithpartial.md) > [partial](./types.interfacetypeoptionswithpartial.partial.md) - -## InterfaceTypeOptionsWithPartial.partial property - -> Warning: This API is now obsolete. -> -> Use the [partial()](./types.partial.md) function instead to get proper TypeScript typings. - -Mark all properties as optional in this type. - -**Signature:** - -```typescript -partial?: boolean; -``` - -## Remarks - -Note that this is NOT reflected in the resulting TypeScript type! diff --git a/markdown/types.intersectionoftypetuple.md b/markdown/types.intersectionoftypetuple.md index 8690bfe..9f3824d 100644 --- a/markdown/types.intersectionoftypetuple.md +++ b/markdown/types.intersectionoftypetuple.md @@ -23,4 +23,4 @@ type IntersectionOfTypeTuple = Tuple extends [ : Record; ``` -**References:** [designType](./types.designtype.md), [MergeIntersection](./types.mergeintersection.md), [IntersectionOfTypeTuple](./types.intersectionoftypetuple.md) +**References:** [MergeIntersection](./types.mergeintersection.md), [IntersectionOfTypeTuple](./types.intersectionoftypetuple.md) diff --git a/markdown/types.md b/markdown/types.md index a7185f9..0c0ae46 100644 --- a/markdown/types.md +++ b/markdown/types.md @@ -32,8 +32,6 @@ Runtime type-validation with derived TypeScript types. | Function | Description | | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | [array(args)](./types.array.md) | Create a type that checks whether the input is an array and all elements conform to the given elementType. | -| [autoCast(type)](./types.autocast.md) | Returns the same type, but with an auto-casting default parser installed. | -| [autoCastAll(type)](./types.autocastall.md) | Create a recursive autocasting version of the given type. | | [booleanAutoCaster(input)](./types.booleanautocaster.md) | | | [createType(impl, override)](./types.createtype.md) | Create a Type from the given type-implementation. | | [intersection(args)](./types.intersection.md) | Intersect the given types. | @@ -54,91 +52,79 @@ Runtime type-validation with derived TypeScript types. ## Interfaces -| Interface | Description | -| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [ArrayTypeConfig](./types.arraytypeconfig.md) | Configuration of additional checks on array types. | -| [Failure](./types.failure.md) | A failed validation result. | -| [InterfaceMergeOptions](./types.interfacemergeoptions.md) | Options for [InterfaceType.withOptional()](./types.interfacetype.withoptional.md), [InterfaceType.withRequired()](./types.interfacetype.withrequired.md) and [InterfaceType.mergeWith()](./types.interfacetype.mergewith.md). | -| [InterfacePickOptions](./types.interfacepickoptions.md) | Options for [InterfaceType.pick()](./types.interfacetype.pick.md) and [InterfaceType.omit()](./types.interfacetype.omit.md). | -| [InterfaceTypeOptions](./types.interfacetypeoptions.md) | Options for [object()](./types.object.md). | -| [InterfaceTypeOptionsWithPartial](./types.interfacetypeoptionswithpartial.md) | | -| [LengthChecksConfig](./types.lengthchecksconfig.md) | | -| [ParserOptions](./types.parseroptions.md) | Options that can be passed to [BaseTypeImpl.withParser()](./types.basetypeimpl.withparser.md). | -| [SimpleTypeOptions](./types.simpletypeoptions.md) | | -| [StringTypeConfig](./types.stringtypeconfig.md) | Configuration of additional checks on string types. | -| [Success](./types.success.md) | A successful validation result. | -| [TypedPropertyInformation](./types.typedpropertyinformation.md) | Interface that provides more detailed type-information about the props and propsInfo properties of the validator. | -| [TypeLink](./types.typelink.md) | An object that has an associated TypeScript type. | -| [ValidationOptions](./types.validationoptions.md) | | -| [Visitor](./types.visitor.md) | Interface for a visitor that is accepted by all types (classic visitor-pattern). | +| Interface | Description | +| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | +| [ArrayTypeConfig](./types.arraytypeconfig.md) | Configuration of additional checks on array types. | +| [Failure](./types.failure.md) | A failed validation result. | +| [InterfaceTypeOptions](./types.interfacetypeoptions.md) | Options for [object()](./types.object.md). | +| [LengthChecksConfig](./types.lengthchecksconfig.md) | | +| [ParserOptions](./types.parseroptions.md) | Options that can be passed to [BaseTypeImpl.withParser()](./types.basetypeimpl.withparser.md). | +| [SimpleTypeOptions](./types.simpletypeoptions.md) | | +| [StringTypeConfig](./types.stringtypeconfig.md) | Configuration of additional checks on string types. | +| [Success](./types.success.md) | A successful validation result. | +| [TypedPropertyInformation](./types.typedpropertyinformation.md) | Interface that provides more detailed type-information about the props and propsInfo properties of the validator. | +| [TypeLink](./types.typelink.md) | An object that has an associated TypeScript type. | +| [ValidationOptions](./types.validationoptions.md) | | +| [Visitor](./types.visitor.md) | Interface for a visitor that is accepted by all types (classic visitor-pattern). | ## Variables -| Variable | Description | -| --------------------------------------------- | -------------------------------------------------------------------------------------------- | -| [autoCastFailure](./types.autocastfailure.md) | Returned by an autocaster to indicate that it is not able to auto-cast the given input. | -| [boolean](./types.boolean.md) | Built-in validator for boolean-values. | -| [brands](./types.brands.md) | The symbol that gives access to the (design-time-only) brands of a Type. | -| [designType](./types.designtype.md) | The symbol that gives access to the (design-time-only) associated TypeScript type of a Type. | -| [int](./types.int.md) | | -| [nullType](./types.nulltype.md) | | -| [number](./types.number.md) | | -| [string](./types.string.md) | Built-in validator for string-values. | -| [undefinedType](./types.undefinedtype.md) | | -| [unknown](./types.unknown.md) | Built-in validator that accepts all values. | -| [unknownArray](./types.unknownarray.md) | Built-in validator that accepts all arrays. | -| [unknownRecord](./types.unknownrecord.md) | Built-in validator that accepts all objects (null is not accepted). | -| [voidType](./types.voidtype.md) | | +| Variable | Description | +| ----------------------------------------- | -------------------------------------------------------------------------------- | +| [boolean](./types.boolean.md) | Built-in validator for boolean-values. | +| [int](./types.int.md) | | +| [nullType](./types.nulltype.md) | | +| [number](./types.number.md) | | +| [string](./types.string.md) | Built-in validator for string-values. | +| [undefinedType](./types.undefinedtype.md) | | +| [unknown](./types.unknown.md) | Built-in validator that accepts all values. | +| [unknownArray](./types.unknownarray.md) | Built-in validator that accepts all arrays. | +| [unknownRecord](./types.unknownrecord.md) | Built-in validator that accepts all objects (null is not accepted). | +| [voidType](./types.voidtype.md) | | ## Type Aliases -| Type Alias | Description | -| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [ArrayViolation](./types.arrayviolation.md) | The supported additional checks on array types. | -| [BasicType](./types.basictype.md) | Basic categories of types. | -| [Branded](./types.branded.md) | Create a Branded type with a given BrandName. | -| [CustomMessage](./types.custommessage.md) | The type for optional custom messages | -| [DeepUnbranded](./types.deepunbranded.md) | Unbrand a given type (recursive). | -| [FailureDetails](./types.failuredetails.md) | Individual message with info about the performed validation for error-reporting. | -| [FullType](./types.fulltype.md) | Result of the [object()](./types.object.md) function. | -| [int](./types.int.md) | | -| [IntersectionOfTypeTuple](./types.intersectionoftypetuple.md) | | -| [LengthViolation](./types.lengthviolation.md) | | -| [LiteralValue](./types.literalvalue.md) | The supported types of literals. | -| [MergeIntersection](./types.mergeintersection.md) | Merge an intersection of types into one type, mostly for tooltip-readability in IDEs. | -| [MergeType](./types.mergetype.md) | Result of the [InterfaceType.withOptional()](./types.interfacetype.withoptional.md), [InterfaceType.withRequired()](./types.interfacetype.withrequired.md) and [InterfaceType.mergeWith()](./types.interfacetype.mergewith.md) methods. | -| [MessageDetails](./types.messagedetails.md) | Individual message details with optional info about the performed validation. | -| [NumberTypeConfig](./types.numbertypeconfig.md) | Configuration of additional checks on numeric types. | -| [NumberViolation](./types.numberviolation.md) | The supported additional checks on numeric types. | -| [ObjectType](./types.objecttype.md) | A type-validator/-parser that validates or parses object-like type ResultType. | -| [OneOrMore](./types.oneormore.md) | An Array with at least one element. | -| [PartialType](./types.partialtype.md) | Result of the [partial()](./types.partial.md) function and the [InterfaceType.toPartial()](./types.interfacetype.topartial.md) method. | -| [PickType](./types.picktype.md) | Result of the [InterfaceType.pick()](./types.interfacetype.pick.md) and [InterfaceType.omit()](./types.interfacetype.omit.md) methods. | -| [PossibleDiscriminator](./types.possiblediscriminator.md) | A description of the property-paths and possible values that might be used to identify this type inside a union. | -| [Primitive](./types.primitive.md) | | -| [Properties](./types.properties.md) | The properties of an object type. | -| [PropertiesInfo](./types.propertiesinfo.md) | Properties of an object type, including per-property optionality. | -| [PropertiesOfTypeTuple](./types.propertiesoftypetuple.md) | | -| [PropertyInfo](./types.propertyinfo.md) | Information about a single property of an object-like type including its optionality. | -| [Result](./types.result.md) | The result of a type validation. | -| [SimpleAcceptVisitor](./types.simpleacceptvisitor.md) | | -| [Simplify](./types.simplify.md) | Flatten the type output to improve type hints as shown in editors. | -| [StringViolation](./types.stringviolation.md) | The supported additional checks on string types. | -| [The](./types.the.md) | Obtains the TypeScript type of the given runtime Type-checker. Aka [TypeOf](./types.typeof.md). | -| [Transposed](./types.transposed.md) | | -| [Type](./types.type.md) | A type-validator/-parser that validates or parses ResultType. | -| [TypeguardFor](./types.typeguardfor.md) | The type of the type-guard that comes with each Type (the \#is method). | -| [TypeguardResult](./types.typeguardresult.md) | The resulting type of a typeguard based on the ResultType of the Type and the given Input. | -| [TypeImpl](./types.typeimpl.md) | The Type with the given type implementation. | -| [TypeOf](./types.typeof.md) | Obtains the TypeScript type of the given runtime Type-checker. Aka [The](./types.the.md). | -| [TypeOfProperties](./types.typeofproperties.md) | Translates the type of a Properties-object into the proper TypeScript type to be used in user-code. | -| [Unbranded](./types.unbranded.md) | Unbrand a given type (not recursive). | -| [UnbrandValues](./types.unbrandvalues.md) | | -| [unknownArray](./types.unknownarray.md) | Built-in validator that accepts all arrays. | -| [unknownRecord](./types.unknownrecord.md) | Built-in validator that accepts all objects (null is not accepted). | -| [ValidationDetails](./types.validationdetails.md) | Information about the performed validation for error-reporting. | -| [ValidationMode](./types.validationmode.md) | The validation mode to use. | -| [ValidationResult](./types.validationresult.md) | The possible return values inside validation and constraint functions. | -| [Validator](./types.validator.md) | The validation-logic as needed by [BaseTypeImpl.withConstraint()](./types.basetypeimpl.withconstraint.md) and [BaseTypeImpl.withValidation()](./types.basetypeimpl.withvalidation.md). | -| [WithBrands](./types.withbrands.md) | | -| [Writable](./types.writable.md) | The opposite of the built-in Readonly<...> type. | +| Type Alias | Description | +| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [ArrayViolation](./types.arrayviolation.md) | The supported additional checks on array types. | +| [BasicType](./types.basictype.md) | Basic categories of types. | +| [Branded](./types.branded.md) | Create a Branded type with a given BrandName. | +| [CustomMessage](./types.custommessage.md) | The type for optional custom messages | +| [DeepUnbranded](./types.deepunbranded.md) | Unbrand a given type (recursive). | +| [FailureDetails](./types.failuredetails.md) | Individual message with info about the performed validation for error-reporting. | +| [FullType](./types.fulltype.md) | | +| [int](./types.int.md) | | +| [IntersectionOfTypeTuple](./types.intersectionoftypetuple.md) | | +| [LengthViolation](./types.lengthviolation.md) | | +| [LiteralValue](./types.literalvalue.md) | The supported types of literals. | +| [MergeIntersection](./types.mergeintersection.md) | Merge an intersection of types into one type, mostly for tooltip-readability in IDEs. | +| [MessageDetails](./types.messagedetails.md) | Individual message details with optional info about the performed validation. | +| [NumberTypeConfig](./types.numbertypeconfig.md) | Configuration of additional checks on numeric types. | +| [NumberViolation](./types.numberviolation.md) | The supported additional checks on numeric types. | +| [ObjectType](./types.objecttype.md) | A type-validator/-parser that validates or parses object-like type ResultType. | +| [OneOrMore](./types.oneormore.md) | An Array with at least one element. | +| [PartialType](./types.partialtype.md) | | +| [PossibleDiscriminator](./types.possiblediscriminator.md) | A description of the property-paths and possible values that might be used to identify this type inside a union. | +| [Primitive](./types.primitive.md) | | +| [Properties](./types.properties.md) | The properties of an object type. | +| [PropertiesInfo](./types.propertiesinfo.md) | Properties of an object type, including per-property optionality. | +| [PropertiesOfTypeTuple](./types.propertiesoftypetuple.md) | | +| [Result](./types.result.md) | The result of a type validation. | +| [StringViolation](./types.stringviolation.md) | The supported additional checks on string types. | +| [The](./types.the.md) | Obtains the TypeScript type of the given runtime Type-checker. Aka [TypeOf](./types.typeof.md). | +| [Transposed](./types.transposed.md) | | +| [Type](./types.type.md) | A type-validator/-parser that validates or parses ResultType. | +| [TypeguardFor](./types.typeguardfor.md) | The type of the type-guard that comes with each Type (the \#is method). | +| [TypeguardResult](./types.typeguardresult.md) | The resulting type of a typeguard based on the ResultType of the Type and the given Input. | +| [TypeImpl](./types.typeimpl.md) | The Type with the given type implementation. | +| [TypeOf](./types.typeof.md) | Obtains the TypeScript type of the given runtime Type-checker. Aka [The](./types.the.md). | +| [TypeOfProperties](./types.typeofproperties.md) | Translates the type of a Properties-object into the proper TypeScript type to be used in user-code. | +| [Unbranded](./types.unbranded.md) | Unbrand a given type (not recursive). | +| [unknownArray](./types.unknownarray.md) | Built-in validator that accepts all arrays. | +| [unknownRecord](./types.unknownrecord.md) | Built-in validator that accepts all objects (null is not accepted). | +| [ValidationDetails](./types.validationdetails.md) | Information about the performed validation for error-reporting. | +| [ValidationMode](./types.validationmode.md) | The validation mode to use. | +| [ValidationResult](./types.validationresult.md) | The possible return values inside validation and constraint functions. | +| [Validator](./types.validator.md) | The validation-logic as needed by [BaseTypeImpl.withConstraint()](./types.basetypeimpl.withconstraint.md) and [BaseTypeImpl.withValidation()](./types.basetypeimpl.withvalidation.md). | +| [WithBrands](./types.withbrands.md) | | +| [Writable](./types.writable.md) | The opposite of the built-in Readonly<...> type. | diff --git a/markdown/types.mergeintersection.md b/markdown/types.mergeintersection.md index cb4a9c9..94f1fcb 100644 --- a/markdown/types.mergeintersection.md +++ b/markdown/types.mergeintersection.md @@ -9,7 +9,9 @@ Merge an intersection of types into one type, mostly for tooltip-readability in **Signature:** ```typescript -type MergeIntersection = T extends Record ? Simplify : T; +type MergeIntersection = T extends Record + ? { + [P in keyof T]: T[P]; + } & {} + : T; ``` - -**References:** [Simplify](./types.simplify.md) diff --git a/markdown/types.mergetype.md b/markdown/types.mergetype.md deleted file mode 100644 index cd268c2..0000000 --- a/markdown/types.mergetype.md +++ /dev/null @@ -1,17 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [MergeType](./types.mergetype.md) - -## MergeType type - -Result of the [InterfaceType.withOptional()](./types.interfacetype.withoptional.md), [InterfaceType.withRequired()](./types.interfacetype.withrequired.md) and [InterfaceType.mergeWith()](./types.interfacetype.mergewith.md) methods. - -**Signature:** - -```typescript -type MergeType = TypeImpl< - InterfaceType & OtherProps>, Simplify & OtherResultType>> ->; -``` - -**References:** [Properties](./types.properties.md), [TypeImpl](./types.typeimpl.md), [InterfaceType](./types.interfacetype.md), [Simplify](./types.simplify.md) diff --git a/markdown/types.numberautocaster.md b/markdown/types.numberautocaster.md index 77c6a26..e10799f 100644 --- a/markdown/types.numberautocaster.md +++ b/markdown/types.numberautocaster.md @@ -18,4 +18,4 @@ declare function numberAutoCaster(input: unknown): number | typeof autoCastFailu **Returns:** -number \| typeof [autoCastFailure](./types.autocastfailure.md) +number \| typeof autoCastFailure diff --git a/markdown/types.object.md b/markdown/types.object.md index 067a069..94e3a14 100644 --- a/markdown/types.object.md +++ b/markdown/types.object.md @@ -10,15 +10,15 @@ Create a type-validator that validates (or parses) an object structure. ```typescript declare function object( - ...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptionsWithPartial, props: Props] + ...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptions, props: Props] ): FullType; ``` ## Parameters -| Parameter | Type | Description | -| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | -| args | \[props: Props\] \| \[name: string, props: Props\] \| \[options: [InterfaceTypeOptionsWithPartial](./types.interfacetypeoptionswithpartial.md), props: Props\] | the options and properties of the new type | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | +| args | \[props: Props\] \| \[name: string, props: Props\] \| \[options: [InterfaceTypeOptions](./types.interfacetypeoptions.md), props: Props\] | the options and properties of the new type | **Returns:** diff --git a/markdown/types.partial.md b/markdown/types.partial.md index 16b7ba6..088a99e 100644 --- a/markdown/types.partial.md +++ b/markdown/types.partial.md @@ -10,15 +10,15 @@ Create a type-validator that validates (or parses) an object structure with only ```typescript declare function partial( - ...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptions, props: Props] + ...args: [props: Props] | [name: string, props: Props] | [options: Omit, props: Props] ): PartialType; ``` ## Parameters -| Parameter | Type | Description | -| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- | -| args | \[props: Props\] \| \[name: string, props: Props\] \| \[options: [InterfaceTypeOptions](./types.interfacetypeoptions.md), props: Props\] | the optional name and (required) properties of the new type | +| Parameter | Type | Description | +| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | +| args | \[props: Props\] \| \[name: string, props: Props\] \| \[options: Omit<[InterfaceTypeOptions](./types.interfacetypeoptions.md), 'partial'>, props: Props\] | the optional name and (required) properties of the new type | **Returns:** diff --git a/markdown/types.partialtype.md b/markdown/types.partialtype.md index 1dc8c3e..d26c98a 100644 --- a/markdown/types.partialtype.md +++ b/markdown/types.partialtype.md @@ -4,12 +4,10 @@ ## PartialType type -Result of the [partial()](./types.partial.md) function and the [InterfaceType.toPartial()](./types.interfacetype.topartial.md) method. - **Signature:** ```typescript -type PartialType = TypeImpl, Simplify>>>>>; +type PartialType = TypeImpl>>>>; ``` -**References:** [Properties](./types.properties.md), [TypeImpl](./types.typeimpl.md), [InterfaceType](./types.interfacetype.md), [Simplify](./types.simplify.md), [TypeOfProperties](./types.typeofproperties.md), [Writable](./types.writable.md) +**References:** [Properties](./types.properties.md), [TypeImpl](./types.typeimpl.md), [InterfaceType](./types.interfacetype.md), [TypeOfProperties](./types.typeofproperties.md), [Writable](./types.writable.md) diff --git a/markdown/types.picktype.md b/markdown/types.picktype.md deleted file mode 100644 index 5fe27a6..0000000 --- a/markdown/types.picktype.md +++ /dev/null @@ -1,17 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [PickType](./types.picktype.md) - -## PickType type - -Result of the [InterfaceType.pick()](./types.interfacetype.pick.md) and [InterfaceType.omit()](./types.interfacetype.omit.md) methods. - -**Signature:** - -```typescript -type PickType = TypeImpl< - InterfaceType>, Simplify>> ->; -``` - -**References:** [Properties](./types.properties.md), [TypeImpl](./types.typeimpl.md), [InterfaceType](./types.interfacetype.md), [Simplify](./types.simplify.md) diff --git a/markdown/types.propertiesinfo.md b/markdown/types.propertiesinfo.md index 3f079d9..d60e33f 100644 --- a/markdown/types.propertiesinfo.md +++ b/markdown/types.propertiesinfo.md @@ -10,8 +10,11 @@ Properties of an object type, including per-property optionality. ```typescript type PropertiesInfo = { - [Key in keyof Props]: PropertyInfo; + [Key in keyof Props]: { + partial: boolean; + type: Props[Key]; + }; }; ``` -**References:** [Properties](./types.properties.md), [PropertyInfo](./types.propertyinfo.md) +**References:** [Properties](./types.properties.md) diff --git a/markdown/types.propertyinfo.md b/markdown/types.propertyinfo.md deleted file mode 100644 index d0377c2..0000000 --- a/markdown/types.propertyinfo.md +++ /dev/null @@ -1,18 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [PropertyInfo](./types.propertyinfo.md) - -## PropertyInfo type - -Information about a single property of an object-like type including its optionality. - -**Signature:** - -```typescript -type PropertyInfo = Type> = { - optional: boolean; - type: T; -}; -``` - -**References:** [Type](./types.type.md) diff --git a/markdown/types.simpleacceptvisitor.md b/markdown/types.simpleacceptvisitor.md deleted file mode 100644 index 7fda617..0000000 --- a/markdown/types.simpleacceptvisitor.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [SimpleAcceptVisitor](./types.simpleacceptvisitor.md) - -## SimpleAcceptVisitor type - -**Signature:** - -```typescript -type SimpleAcceptVisitor = (type: SimpleType, visitor: Visitor) => R; -``` - -**References:** [SimpleType](./types.simpletype.md), [Visitor](./types.visitor.md) diff --git a/markdown/types.simpletypeoptions.md b/markdown/types.simpletypeoptions.md index 0abf100..bdd1fb2 100644 --- a/markdown/types.simpletypeoptions.md +++ b/markdown/types.simpletypeoptions.md @@ -14,7 +14,7 @@ interface SimpleTypeOptions | Property | Modifiers | Type | Description | | -------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------- | ------------ | -| [acceptVisitor?](./types.simpletypeoptions.acceptvisitor.md) | | [SimpleAcceptVisitor](./types.simpleacceptvisitor.md)<ResultType, TypeConfig> | _(Optional)_ | +| [acceptVisitor?](./types.simpletypeoptions.acceptvisitor.md) | | SimpleAcceptVisitor<ResultType, TypeConfig> | _(Optional)_ | | [autoCaster?](./types.simpletypeoptions.autocaster.md) | | [BaseTypeImpl](./types.basetypeimpl.md)<ResultType, TypeConfig>\['autoCaster'\] | _(Optional)_ | | [combineConfig?](./types.simpletypeoptions.combineconfig.md) | | [BaseTypeImpl](./types.basetypeimpl.md)<ResultType, TypeConfig>\['combineConfig'\] | _(Optional)_ | | [enumerableLiteralDomain?](./types.simpletypeoptions.enumerableliteraldomain.md) | | [BaseTypeImpl](./types.basetypeimpl.md)<ResultType, TypeConfig>\['enumerableLiteralDomain'\] | _(Optional)_ | diff --git a/markdown/types.simplify.md b/markdown/types.simplify.md deleted file mode 100644 index 025d61d..0000000 --- a/markdown/types.simplify.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [Simplify](./types.simplify.md) - -## Simplify type - -Flatten the type output to improve type hints as shown in editors. - -**Signature:** - -```typescript -type Simplify = { - [P in keyof T]: T[P]; -} & {}; -``` diff --git a/markdown/types.typeof.md b/markdown/types.typeof.md index 7278dfd..018caef 100644 --- a/markdown/types.typeof.md +++ b/markdown/types.typeof.md @@ -15,5 +15,3 @@ type TypeOf = T extends { ? Q : never; ``` - -**References:** [designType](./types.designtype.md) diff --git a/markdown/types.unbrandvalues.md b/markdown/types.unbrandvalues.md deleted file mode 100644 index 7a4f7de..0000000 --- a/markdown/types.unbrandvalues.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [@skunkteam/types](./types.md) > [UnbrandValues](./types.unbrandvalues.md) - -## UnbrandValues type - -**Signature:** - -```typescript -type UnbrandValues = { - [P in keyof T]: DeepUnbranded; -}; -``` - -**References:** [DeepUnbranded](./types.deepunbranded.md) diff --git a/markdown/types.validationerror.details.md b/markdown/types.validationerror.details.md index b1deb80..d52bc3e 100644 --- a/markdown/types.validationerror.details.md +++ b/markdown/types.validationerror.details.md @@ -7,5 +7,5 @@ **Signature:** ```typescript -readonly details: OneOrMore; +details: OneOrMore; ``` diff --git a/markdown/types.validationerror.input.md b/markdown/types.validationerror.input.md index 94f8280..438aff9 100644 --- a/markdown/types.validationerror.input.md +++ b/markdown/types.validationerror.input.md @@ -7,5 +7,5 @@ **Signature:** ```typescript -readonly input: unknown; +input: unknown; ``` diff --git a/markdown/types.validationerror.md b/markdown/types.validationerror.md index 345a434..3a23910 100644 --- a/markdown/types.validationerror.md +++ b/markdown/types.validationerror.md @@ -24,11 +24,11 @@ Is itself also a [Failure](./types.failure.md) and can be used as such in APIs. | Property | Modifiers | Type | Description | | --------------------------------------------- | --------------------- | ---------------------------------------------------------------------------------------------------- | ----------- | -| [details](./types.validationerror.details.md) | readonly | [OneOrMore](./types.oneormore.md)<[FailureDetails](./types.failuredetails.md)> | | -| [input](./types.validationerror.input.md) | readonly | unknown | | +| [details](./types.validationerror.details.md) | | [OneOrMore](./types.oneormore.md)<[FailureDetails](./types.failuredetails.md)> | | +| [input](./types.validationerror.input.md) | | unknown | | | [name](./types.validationerror.name.md) | readonly | (not declared) | | | [ok](./types.validationerror.ok.md) | readonly | (not declared) | | -| [type](./types.validationerror.type.md) | readonly | [BaseTypeImpl](./types.basetypeimpl.md)<unknown> | | +| [type](./types.validationerror.type.md) | | [BaseTypeImpl](./types.basetypeimpl.md)<unknown> | | ## Methods diff --git a/markdown/types.validationerror.type.md b/markdown/types.validationerror.type.md index 731d776..4d442cf 100644 --- a/markdown/types.validationerror.type.md +++ b/markdown/types.validationerror.type.md @@ -7,5 +7,5 @@ **Signature:** ```typescript -readonly type: BaseTypeImpl; +type: BaseTypeImpl; ``` diff --git a/markdown/types.validationresult.md b/markdown/types.validationresult.md index 2877f26..0aa38ba 100644 --- a/markdown/types.validationresult.md +++ b/markdown/types.validationresult.md @@ -9,11 +9,11 @@ The possible return values inside validation and constraint functions. **Signature:** ```typescript -type ValidationResult = undefined | boolean | string | MessageDetails | Iterable; +type ValidationResult = boolean | string | MessageDetails | Array; ``` **References:** [MessageDetails](./types.messagedetails.md) ## Remarks -The validation is considered a success if the result is `true` or `undefined` or an empty iterator, anything else is considered to be a failure. +The validation is considered a success if the result is `true` or an empty array, anything else is considered to be a failure. diff --git a/markdown/types.withbrands.md b/markdown/types.withbrands.md index c538dd0..7c9da1a 100644 --- a/markdown/types.withbrands.md +++ b/markdown/types.withbrands.md @@ -13,5 +13,3 @@ type WithBrands = T & { }; }; ``` - -**References:** [brands](./types.brands.md) diff --git a/src/types/intersection.ts b/src/types/intersection.ts index e0c0036..02caf89 100644 --- a/src/types/intersection.ts +++ b/src/types/intersection.ts @@ -43,10 +43,7 @@ export class IntersectionType = { function selectBound(key: T, current: NumberTypeConfig, update: NumberTypeConfig): Bound { const exclKey = `${key}Exclusive` as const; - const onlyTheBound = (c: NumberTypeConfig) => ({ [key]: c[key], [exclKey]: c[exclKey] }) as Bound; + const onlyTheBound = (c: NumberTypeConfig) => ({ [key]: c[key], [exclKey]: c[exclKey] } as Bound); const currentPosition: number | undefined = current[key] ?? current[exclKey]; if (currentPosition == null) return onlyTheBound(update); diff --git a/src/types/record.ts b/src/types/record.ts index c14667e..c1741e4 100644 --- a/src/types/record.ts +++ b/src/types/record.ts @@ -23,12 +23,7 @@ export class RecordType< /** {@inheritdoc BaseTypeImpl.typeConfig} */ readonly typeConfig: undefined; - constructor( - readonly keyType: KeyTypeImpl, - readonly valueType: ValueTypeImpl, - name?: string, - readonly strict = true, - ) { + constructor(readonly keyType: KeyTypeImpl, readonly valueType: ValueTypeImpl, name?: string, readonly strict = true) { super(); this.isDefaultName = !name; this.name = name || `Record<${keyType.name}, ${valueType.name}>`; diff --git a/src/types/union.ts b/src/types/union.ts index 8d7428f..d162526 100644 --- a/src/types/union.ts +++ b/src/types/union.ts @@ -31,10 +31,7 @@ export class UnionType< /** {@inheritdoc BaseTypeImpl.typeConfig} */ readonly typeConfig: undefined; - constructor( - readonly types: Types, - name?: string, - ) { + constructor(readonly types: Types, name?: string) { super(); this.isDefaultName = !name; this.name = name || types.map(type => bracketsIfNeeded(type.name, '|')).join(' | ');