Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions etc/types.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export abstract class BaseTypeImpl<ResultType, TypeConfig = unknown> implements
withBrand<const BrandName extends string>(name: BrandName): Type<Branded<ResultType, BrandName>, TypeConfig>;
withConfig<const BrandName extends string>(name: BrandName, newConfig: TypeConfig): Type<Branded<ResultType, BrandName>, TypeConfig>;
withConstraint<const BrandName extends string>(name: BrandName, constraint: Validator<ResultType>): Type<Branded<ResultType, BrandName>, TypeConfig>;
withDefault(...args: [value: DeepUnbranded<ResultType>] | [name: string, value: DeepUnbranded<ResultType>] | [options: WithDefaultOptions, value: DeepUnbranded<ResultType>]): this;
withName(name: string): this;
withParser(...args: [newConstructor: (i: unknown) => unknown] | [name: string, newConstructor: (i: unknown) => unknown] | [options: ParserOptions, newConstructor: (i: unknown) => unknown]): this;
withValidation(validation: Validator<ResultType>): this;
Expand All @@ -110,9 +109,6 @@ export type Branded<T, BrandName extends string> = T extends WithBrands<infer Ba
// @public
export const brands: unique symbol;

// @public
export function checkOneOrMore<T>(arr: T[]): OneOrMore<T>;

// @public
export function createType<Impl extends BaseTypeImpl<any, any>>(impl: Impl, override?: Partial<Record<keyof BaseTypeImpl<any, any> | 'typeValidator' | 'typeParser' | 'customValidators', PropertyDescriptor>>): TypeImpl<Impl>;

Expand Down Expand Up @@ -236,9 +232,6 @@ export class IntersectionType<Types extends OneOrMore<BaseObjectLikeTypeImpl<unk
protected typeValidator(input: unknown, options: ValidationOptions): Result<IntersectionOfTypeTuple<Types>>;
}

// @public
export function isOneOrMore<T>(arr: T[]): arr is OneOrMore<T>;

// @public
export function isType(value: unknown): value is Type<unknown>;

Expand Down Expand Up @@ -675,15 +668,13 @@ export interface Visitor<R> {
// (undocumented)
visitCustomType(type: BaseTypeImpl<unknown>): R;
// (undocumented)
visitIntersectionType(type: IntersectionType<OneOrMore<BaseObjectLikeTypeImpl<unknown>>>): R;
// (undocumented)
visitKeyofType(type: KeyofType<Record<any, any>, any>): R;
// (undocumented)
visitLiteralType(type: LiteralType<LiteralValue>): R;
// (undocumented)
visitNumberType(type: BaseTypeImpl<number, NumberTypeConfig>): R;
// (undocumented)
visitObjectType(type: InterfaceType<Properties, unknownRecord>): R;
visitObjectLikeType(type: BaseObjectLikeTypeImpl<unknown>): R;
// (undocumented)
visitRecordType(type: RecordType<BaseTypeImpl<number | string>, number | string, BaseTypeImpl<unknown>, unknown>): R;
// (undocumented)
Expand All @@ -708,12 +699,6 @@ export type WithBrands<T, BrandNames extends string> = T & {
};
};

// @public
export interface WithDefaultOptions {
clone?: boolean;
name?: string;
}

// @public
export type Writable<T> = {
-readonly [P in keyof T]: T[P];
Expand Down
1 change: 0 additions & 1 deletion markdown/types.basetypeimpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ All type-implementations must extend this base class. Use [createType()](./types
| [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. |
| [withDefault(args)](./types.basetypeimpl.withdefault.md) | | Define a new type with the same specs, but with the given default value. |
| [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. |
27 changes: 0 additions & 27 deletions markdown/types.basetypeimpl.withdefault.md

This file was deleted.

23 changes: 0 additions & 23 deletions markdown/types.checkoneormore.md

This file was deleted.

27 changes: 0 additions & 27 deletions markdown/types.isoneormore.md

This file was deleted.

3 changes: 0 additions & 3 deletions markdown/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ Runtime type-validation with derived TypeScript types.
| [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) | |
| [checkOneOrMore(arr)](./types.checkoneormore.md) | Returns the original array if and only if it has at least one element. |
| [createType(impl, override)](./types.createtype.md) | Create a Type from the given type-implementation. |
| [intersection(args)](./types.intersection.md) | Intersect the given types. |
| [isOneOrMore(arr)](./types.isoneormore.md) | Type guard for <code>OneOrMore</code> |
| [isType(value)](./types.istype.md) | Type-guard that asserts that a given value is a Type. |
| [keyof(args)](./types.keyof.md) | |
| [literal(value)](./types.literal.md) | |
Expand Down Expand Up @@ -73,7 +71,6 @@ Runtime type-validation with derived TypeScript types.
| [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). |
| [WithDefaultOptions](./types.withdefaultoptions.md) | Options that can be passed to [BaseTypeImpl.withDefault()](./types.basetypeimpl.withdefault.md)<!-- -->. |

## Variables

Expand Down
4 changes: 0 additions & 4 deletions markdown/types.oneormore.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ An Array with at least one element.
```typescript
type OneOrMore<T> = [T, ...T[]];
```

## Remarks

Note that this type does not disable the mutable methods of the array, which may still invalidate the non-emptiness of the array.
3 changes: 1 addition & 2 deletions markdown/types.visitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ interface Visitor<R>
| [visitArrayType(type)](./types.visitor.visitarraytype.md) | |
| [visitBooleanType(type)](./types.visitor.visitbooleantype.md) | |
| [visitCustomType(type)](./types.visitor.visitcustomtype.md) | |
| [visitIntersectionType(type)](./types.visitor.visitintersectiontype.md) | |
| [visitKeyofType(type)](./types.visitor.visitkeyoftype.md) | |
| [visitLiteralType(type)](./types.visitor.visitliteraltype.md) | |
| [visitNumberType(type)](./types.visitor.visitnumbertype.md) | |
| [visitObjectType(type)](./types.visitor.visitobjecttype.md) | |
| [visitObjectLikeType(type)](./types.visitor.visitobjectliketype.md) | |
| [visitRecordType(type)](./types.visitor.visitrecordtype.md) | |
| [visitStringType(type)](./types.visitor.visitstringtype.md) | |
| [visitUnionType(type)](./types.visitor.visituniontype.md) | |
Expand Down
21 changes: 0 additions & 21 deletions markdown/types.visitor.visitintersectiontype.md

This file was deleted.

21 changes: 21 additions & 0 deletions markdown/types.visitor.visitobjectliketype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@skunkteam/types](./types.md) &gt; [Visitor](./types.visitor.md) &gt; [visitObjectLikeType](./types.visitor.visitobjectliketype.md)

## Visitor.visitObjectLikeType() method

**Signature:**

```typescript
visitObjectLikeType(type: BaseObjectLikeTypeImpl<unknown>): R;
```

## Parameters

| Parameter | Type | Description |
| --------- | ---------------------------------------------------------------------------------- | ----------- |
| type | [BaseObjectLikeTypeImpl](./types.baseobjectliketypeimpl.md)<!-- -->&lt;unknown&gt; | |

**Returns:**

R
21 changes: 0 additions & 21 deletions markdown/types.visitor.visitobjecttype.md

This file was deleted.

17 changes: 0 additions & 17 deletions markdown/types.withdefaultoptions.clone.md

This file was deleted.

20 changes: 0 additions & 20 deletions markdown/types.withdefaultoptions.md

This file was deleted.

13 changes: 0 additions & 13 deletions markdown/types.withdefaultoptions.name.md

This file was deleted.

6 changes: 5 additions & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,14 @@ export type DeepUnbranded<T> = T extends readonly [any, ...any[]] | readonly []
: T extends ReadonlyArray<infer E>
? ReadonlyArray<DeepUnbranded<E>>
: T extends Record<string, unknown>
? UnbrandValues<Unbranded<T>>
? UnbrandRecordLike<Unbranded<T>>
: Unbranded<T>;

export type UnbrandValues<T> = { [P in keyof T]: DeepUnbranded<T[P]> };
/** Check if the key type of the record-like structure (could also be an object) is branded. In that case, explicitely unbrand the keytype */
export type UnbrandRecordLike<T> = keyof T extends WithBrands<string, any> | WithBrands<number, any>
? Record<Unbranded<keyof T>, DeepUnbranded<T[keyof T]>>
: UnbrandValues<T>;

/**
* The properties of an object type.
Expand Down
Loading
Loading