Skip to content

Commit

Permalink
Updated API docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
untio11 committed Nov 18, 2024
1 parent a282744 commit 75caf44
Show file tree
Hide file tree
Showing 62 changed files with 198 additions and 795 deletions.
119 changes: 34 additions & 85 deletions etc/types.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ export interface ArrayTypeConfig extends LengthChecksConfig {
// @public
export type ArrayViolation = LengthViolation;

// @public
export function autoCast<T extends BaseTypeImpl<unknown>>(type: T): T;

// @public
export function autoCastAll<T extends BaseTypeImpl<unknown>>(type: T): T;

// @public
export const autoCastFailure: unique symbol;

// @public
export abstract class BaseObjectLikeTypeImpl<ResultType, TypeConfig = unknown> extends BaseTypeImpl<ResultType, TypeConfig> {
and<Other extends BaseObjectLikeTypeImpl<any, any>>(_other: Other): ObjectType<MergeIntersection<ResultType & Other[typeof designType]>> & TypedPropertyInformation<this['props'] & Other['props']>;
Expand All @@ -50,7 +41,7 @@ export abstract class BaseObjectLikeTypeImpl<ResultType, TypeConfig = unknown> e
abstract readonly possibleDiscriminators: readonly PossibleDiscriminator[];
// (undocumented)
abstract readonly props: Properties;
protected get propsArray(): ReadonlyArray<[string, PropertyInfo]>;
protected get propsArray(): ReadonlyArray<[string, Type<unknown>]>;
// (undocumented)
abstract readonly propsInfo: PropertiesInfo;
}
Expand All @@ -62,15 +53,16 @@ export abstract class BaseTypeImpl<ResultType, TypeConfig = unknown> implements
abstract accept<R>(visitor: Visitor<R>): R;
andThen<Return, RestArgs extends unknown[]>(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<ResultType, TypeConfig>, 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<ResultType>;
protected createAutoCastAllType(): this;
protected createResult(input: unknown, result: unknown, validatorResult: ValidationResult): Result<ResultType>;
protected readonly customValidators: ReadonlyArray<Validator<unknown>>;
readonly enumerableLiteralDomain?: Iterable<LiteralValue>;
extendWith<const E>(factory: (type: this) => E): this & E;
get is(): TypeguardFor<ResultType>;
Expand Down Expand Up @@ -104,19 +96,17 @@ export function booleanAutoCaster(input: unknown): boolean | typeof autoCastFail
export type Branded<T, BrandName extends string> = T extends WithBrands<infer Base, infer ExistingBrands> ? WithBrands<Base, BrandName | ExistingBrands> : WithBrands<T, BrandName>;

// @public
export const brands: unique symbol;

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

// @public
export type CustomMessage<T, E = void> = undefined | string | ((got: string, input: T, explanation: E) => string);

// @public
export type DeepUnbranded<T> = T extends readonly [any, ...any[]] | readonly [] ? UnbrandValues<Unbranded<T>> : T extends Array<infer E> ? Array<DeepUnbranded<E>> : T extends ReadonlyArray<infer E> ? ReadonlyArray<DeepUnbranded<E>> : T extends Record<string, unknown> ? UnbrandValues<Unbranded<T>> : Unbranded<T>;

// @public
export const designType: unique symbol;
export type DeepUnbranded<T> = T extends ReadonlyArray<unknown> ? {
[P in keyof T & number]: DeepUnbranded<T[P]>;
} : T extends Record<string, unknown> ? Omit<{
[P in keyof T]: DeepUnbranded<T[P]>;
}, typeof brands> : Unbranded<T>;

// @public
export interface Failure {
Expand All @@ -131,8 +121,8 @@ export interface Failure {
// @public
export type FailureDetails = ValidationDetails & MessageDetails;

// @public
export type FullType<Props extends Properties> = TypeImpl<InterfaceType<Simplify<Props>, Simplify<TypeOfProperties<Writable<Props>>>>>;
// @public (undocumented)
export type FullType<Props extends Properties> = TypeImpl<InterfaceType<Props, TypeOfProperties<Writable<Props>>>>;

// @public (undocumented)
export type int = The<typeof int>;
Expand All @@ -141,35 +131,18 @@ export type int = The<typeof int>;
export const int: Type<Branded<number, 'int'>, 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<Props extends Properties, ResultType extends unknownRecord> extends BaseObjectLikeTypeImpl<ResultType> implements TypedPropertyInformation<Props> {
export class InterfaceType<Props extends Properties, ResultType> extends BaseObjectLikeTypeImpl<ResultType> implements TypedPropertyInformation<Props> {
constructor(
propsInfo: PropertiesInfo<Props>, options: InterfaceTypeOptions);
props: Props, options: InterfaceTypeOptions);
accept<R>(visitor: Visitor<R>): 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<OtherProps extends Properties, OtherType extends unknownRecord>(...args: [type: InterfaceType<OtherProps, OtherType>] | [name: string, type: InterfaceType<OtherProps, OtherType>] | [options: InterfaceMergeOptions, type: InterfaceType<OtherProps, OtherType>]): MergeType<Props, ResultType, OtherProps, OtherType>;
readonly name: string;
omit<const Key extends keyof Props & keyof ResultType & string>(...args: [keys: OneOrMore<Key>] | [name: string, keys: OneOrMore<Key>] | [options: InterfacePickOptions, keys: OneOrMore<Key>]): PickType<Props, ResultType, Exclude<keyof Props & keyof ResultType & string, Key>>;
// (undocumented)
readonly options: InterfaceTypeOptions;
pick<const Key extends keyof Props & keyof ResultType & string>(...args: [keys: OneOrMore<Key>] | [name: string, keys: OneOrMore<Key>] | [options: InterfacePickOptions, keys: OneOrMore<Key>]): PickType<Props, ResultType, Key>;
// (undocumented)
readonly possibleDiscriminators: readonly PossibleDiscriminator[];
// (undocumented)
Expand All @@ -179,21 +152,15 @@ export class InterfaceType<Props extends Properties, ResultType extends unknownR
toPartial(name?: string): PartialType<Props>;
readonly typeConfig: undefined;
protected typeValidator(input: unknown, options: ValidationOptions): Result<ResultType>;
withOptional<PartialProps extends Properties>(...args: [props: PartialProps] | [name: string, props: PartialProps] | [options: InterfaceMergeOptions, props: PartialProps]): MergeType<Props, ResultType, PartialProps, Partial<TypeOfProperties<Writable<PartialProps>>>>;
withRequired<OtherProps extends Properties>(...args: [props: OtherProps] | [name: string, props: OtherProps] | [options: InterfaceMergeOptions, props: OtherProps]): MergeType<Props, ResultType, OtherProps, TypeOfProperties<Writable<OtherProps>>>;
withOptional<PartialProps extends Properties>(...args: [props: PartialProps] | [name: string, props: PartialProps]): TypeImpl<BaseObjectLikeTypeImpl<MergeIntersection<ResultType & Partial<TypeOfProperties<Writable<PartialProps>>>>>> & TypedPropertyInformation<Props & PartialProps>;
}

// @public
export interface InterfaceTypeOptions {
checkOnly?: boolean;
name?: string;
strictMissingKeys?: boolean;
}

// @public (undocumented)
export interface InterfaceTypeOptionsWithPartial extends InterfaceTypeOptions {
// @deprecated
partial?: boolean;
strictMissingKeys?: boolean;
}

// @public
Expand Down Expand Up @@ -282,10 +249,9 @@ export class LiteralType<ResultType extends LiteralValue> extends BaseTypeImpl<R
export type LiteralValue = string | number | boolean | null | undefined | void;

// @public
export type MergeIntersection<T> = T extends Record<PropertyKey, unknown> ? Simplify<T> : T;

// @public
export type MergeType<Props extends Properties, ResultType, OtherProps extends Properties, OtherResultType> = TypeImpl<InterfaceType<Simplify<Omit<Props, keyof OtherProps> & OtherProps>, Simplify<Omit<ResultType, keyof OtherResultType> & OtherResultType>>>;
export type MergeIntersection<T> = T extends Record<PropertyKey, unknown> ? {
[P in keyof T]: T[P];
} & {} : T;

// @public
export type MessageDetails = Partial<ValidationDetails> & {
Expand Down Expand Up @@ -358,7 +324,7 @@ export type NumberTypeConfig = {
export type NumberViolation = 'min' | 'max' | 'multipleOf';

// @public
export function object<Props extends Properties>(...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptionsWithPartial, props: Props]): FullType<Props>;
export function object<Props extends Properties>(...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptions, props: Props]): FullType<Props>;

// @public
export type ObjectType<ResultType, TypeConfig = unknown> = TypeImpl<BaseObjectLikeTypeImpl<ResultType, TypeConfig>>;
Expand All @@ -373,17 +339,14 @@ export interface ParserOptions {
}

// @public
export function partial<Props extends Properties>(...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptions, props: Props]): PartialType<Props>;
export function partial<Props extends Properties>(...args: [props: Props] | [name: string, props: Props] | [options: Omit<InterfaceTypeOptions, 'partial'>, props: Props]): PartialType<Props>;

// @public
export type PartialType<Props extends Properties> = TypeImpl<InterfaceType<Simplify<Props>, Simplify<Partial<TypeOfProperties<Writable<Props>>>>>>;
// @public (undocumented)
export type PartialType<Props extends Properties> = TypeImpl<InterfaceType<Props, Partial<TypeOfProperties<Writable<Props>>>>>;

// @public (undocumented)
export function pattern<const BrandName extends string>(name: BrandName, regExp: RegExp, customMessage?: StringTypeConfig['customMessage']): Type<Branded<string, BrandName>, StringTypeConfig>;

// @public
export type PickType<Props extends Properties, ResultType, Key extends keyof Props & keyof ResultType & string> = TypeImpl<InterfaceType<Simplify<Pick<Props, Key>>, Simplify<Pick<ResultType, Key>>>>;

// @public
export type PossibleDiscriminator = {
readonly path: readonly string[];
Expand Down Expand Up @@ -411,7 +374,10 @@ export type Properties = Record<string, Type<any>>;

// @public
export type PropertiesInfo<Props extends Properties = Properties> = {
[Key in keyof Props]: PropertyInfo<Props[Key]>;
[Key in keyof Props]: {
partial: boolean;
type: Props[Key];
};
};

// @public (undocumented)
Expand All @@ -421,12 +387,6 @@ export type PropertiesOfTypeTuple<Tuple> = Tuple extends [{
readonly props: infer A;
}, ...infer Rest] ? MergeIntersection<A & PropertiesOfTypeTuple<Rest>> : Properties;

// @public
export type PropertyInfo<T extends Type<unknown> = Type<unknown>> = {
optional: boolean;
type: T;
};

// @public
export function record<KeyType extends number | string, ValueType>(...args: [name: string, keyType: BaseTypeImpl<KeyType>, valueType: BaseTypeImpl<ValueType>, strict?: boolean] | [keyType: BaseTypeImpl<KeyType>, valueType: BaseTypeImpl<ValueType>, strict?: boolean]): TypeImpl<RecordType<BaseTypeImpl<KeyType>, KeyType, BaseTypeImpl<ValueType>, ValueType>>;

Expand Down Expand Up @@ -456,9 +416,6 @@ export { reportError_2 as reportError }
// @public
export type Result<T> = Success<T> | Failure;

// @public (undocumented)
export type SimpleAcceptVisitor<ResultType, TypeConfig> = <R>(type: SimpleType<ResultType, TypeConfig>, visitor: Visitor<R>) => R;

// @public
export class SimpleType<ResultType, TypeConfig> extends BaseTypeImpl<ResultType, TypeConfig> {
accept<R>(visitor: Visitor<R>): R;
Expand All @@ -472,6 +429,8 @@ export class SimpleType<ResultType, TypeConfig> extends BaseTypeImpl<ResultType,

// @public (undocumented)
export interface SimpleTypeOptions<ResultType, TypeConfig> {
// Warning: (ae-forgotten-export) The symbol "SimpleAcceptVisitor" needs to be exported by the entry point index.d.ts
//
// (undocumented)
acceptVisitor?: SimpleAcceptVisitor<ResultType, TypeConfig>;
// (undocumented)
Expand All @@ -486,11 +445,6 @@ export interface SimpleTypeOptions<ResultType, TypeConfig> {
typeConfig: BaseTypeImpl<ResultType, TypeConfig>['typeConfig'];
}

// @public
export type Simplify<T> = {
[P in keyof T]: T[P];
} & {};

// @public
export const string: Type<string, StringTypeConfig>;

Expand Down Expand Up @@ -561,11 +515,6 @@ export type TypeOfProperties<T extends Properties> = {
// @public
export type Unbranded<T> = T extends WithBrands<infer Base, any> ? Base : T;

// @public (undocumented)
export type UnbrandValues<T> = {
[P in keyof T]: DeepUnbranded<T[P]>;
};

// @public (undocumented)
export const undefinedType: TypeImpl<LiteralType<undefined>>;

Expand Down Expand Up @@ -623,17 +572,17 @@ export type ValidationDetails = {
// @public
export class ValidationError extends Error implements Failure {
// (undocumented)
readonly details: OneOrMore<FailureDetails>;
details: OneOrMore<FailureDetails>;
static fromFailure(failure: Failure): ValidationError;
// (undocumented)
readonly input: unknown;
input: unknown;
// (undocumented)
readonly name = "ValidationError";
// (undocumented)
readonly ok = false;
static try<Return>({ type, input }: Pick<Failure, 'type' | 'input'>, fn: () => Return): Result<Return>;
// (undocumented)
readonly type: BaseTypeImpl<unknown>;
type: BaseTypeImpl<unknown>;
}

// @public
Expand All @@ -648,7 +597,7 @@ export interface ValidationOptions {
}

// @public
export type ValidationResult = undefined | boolean | string | MessageDetails | Iterable<string | MessageDetails>;
export type ValidationResult = boolean | string | MessageDetails | Array<string | MessageDetails>;

// @public
export type Validator<ResultType> = (input: ResultType, options: ValidationOptions) => ValidationResult;
Expand Down
27 changes: 0 additions & 27 deletions markdown/types.autocast.md

This file was deleted.

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

This file was deleted.

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

This file was deleted.

2 changes: 1 addition & 1 deletion markdown/types.baseobjectliketypeimpl.and.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and<Other extends BaseObjectLikeTypeImpl<any, any>>(_other: Other): ObjectType<M
**Returns:**
[ObjectType](./types.objecttype.md)<!-- -->&lt;[MergeIntersection](./types.mergeintersection.md)<!-- -->&lt;ResultType &amp; Other\[typeof [designType](./types.designtype.md)<!-- -->\]&gt;&gt; &amp; [TypedPropertyInformation](./types.typedpropertyinformation.md)<!-- -->&lt;this\['props'\] &amp; Other\['props'\]&gt;
[ObjectType](./types.objecttype.md)<!-- -->&lt;[MergeIntersection](./types.mergeintersection.md)<!-- -->&lt;ResultType &amp; Other\[typeof designType\]&gt;&gt; &amp; [TypedPropertyInformation](./types.typedpropertyinformation.md)<!-- -->&lt;this\['props'\] &amp; Other\['props'\]&gt;
## Remarks
Expand Down
Loading

0 comments on commit 75caf44

Please sign in to comment.