Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/typebox/src/typebox.ts>TypeBuilder

JSON Schema Type Builder with Static Type Resolution for TypeScript
Go to Latest
class TypeBuilder
import { TypeBuilder } from "https://deno.land/x/typebox@0.25.12/src/typebox.ts";

Methods

protected
Clone(value: any): any

Clones the given value

protected
Create<T>(schema: Omit<T, "static" | "params">): T

Use this function to return TSchema with static and params omitted

Any(options?: SchemaOptions): TAny

Standard Creates a any type

Array<T extends TSchema>(items: T, options?: ArrayOptions): TArray<T>

Standard Creates a array type

Standard Creates a boolean type

Constructor<T extends TTuple<TSchema[]>, U extends TSchema>(
parameters: T,
returns: U,
options?: SchemaOptions,
): TConstructor<TupleToArray<T>, U>

Extended Creates a constructor type

Constructor<T extends TSchema[], U extends TSchema>(
parameters: [...T],
returns: U,
options?: SchemaOptions,
): TConstructor<T, U>

Extended Creates a constructor type

ConstructorParameters<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TConstructorParameters<T>

Extended Creates a tuple type from this constructors parameters

Date(options?: DateOptions): TDate

Extended Creates a Date type

Enum<T extends Record<string, string | number>>(item: T, options?: SchemaOptions): TEnum<T>

Standard Creates a enum type

Function<T extends TTuple<TSchema[]>, U extends TSchema>(
parameters: T,
returns: U,
options?: SchemaOptions,
): TFunction<TupleToArray<T>, U>

Extended Creates a function type

Function<T extends TSchema[], U extends TSchema>(
parameters: [...T],
returns: U,
options?: SchemaOptions,
): TFunction<T, U>

Extended Creates a function type

InstanceType<T extends TConstructor<any[], any>>(schema: T, options?: SchemaOptions): TInstanceType<T>

Extended Creates a type from this constructors instance type

Standard Creates a integer type

Intersect<T extends TObject[]>(objects: [...T], options?: ObjectOptions): TIntersect<T>

Standard Creates a intersect type.

KeyOf<T extends TObject>(object: T, options?: SchemaOptions): TKeyOf<T>

Standard Creates a keyof type

Literal<T extends TLiteralValue>(value: T, options?: SchemaOptions): TLiteral<T>

Standard Creates a literal type.

Standard Creates a never type

Standard Creates a null type

Standard Creates a number type

Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>

Standard Creates an object type

Omit<T extends TObject, K extends TUnion<TLiteral<string>[]>>(
schema: T,
keys: K,
options?: ObjectOptions,
): TOmit<T, UnionStringLiteralToTuple<K>>

Standard Creates a new object type whose keys are omitted from the given source type

Omit<T extends TObject, K extends ObjectPropertyKeys<T>[]>(
schema: T,
keys: readonly [...K],
options?: ObjectOptions,
): TOmit<T, K>

Standard Creates a new object type whose keys are omitted from the given source type

Optional<T extends TSchema>(item: T): TOptional<T>

Creates a optional property

Parameters<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TParameters<T>

Extended Creates a tuple type from this functions parameters

Partial<T extends TObject>(schema: T, options?: ObjectOptions): TPartial<T>

Standard Creates an object type whose properties are all optional

Pick<T extends TObject, K extends TUnion<TLiteral<string>[]>>(
schema: T,
keys: K,
options?: ObjectOptions,
): TPick<T, UnionStringLiteralToTuple<K>>

Standard Creates a new object type whose keys are picked from the given source type

Pick<T extends TObject, K extends ObjectPropertyKeys<T>[]>(
schema: T,
keys: readonly [...K],
options?: ObjectOptions,
): TPick<T, K>

Standard Creates a new object type whose keys are picked from the given source type

Promise<T extends TSchema>(item: T, options?: SchemaOptions): TPromise<T>

Extended Creates a Promise type

Readonly<T extends TSchema>(item: T): TReadonly<T>

Creates a readonly property

Creates a readonly optional property

Record<K extends TUnion<TLiteral[]>, T extends TSchema>(
key: K,
schema: T,
options?: ObjectOptions,
): TObject<TRecordProperties<K, T>>

Standard Creates an object whose properties are derived from the given string literal union.

Record<K extends TString | TNumeric, T extends TSchema>(
key: K,
schema: T,
options?: ObjectOptions,
): TRecord<K, T>

Standard Creates a record type

Recursive<T extends TSchema>(callback: (self: TSelf) => T, options?: SchemaOptions): TRecursive<T>

Standard Creates recursive type

Ref<T extends TSchema>(schema: T, options?: SchemaOptions): TRef<T>

Standard Creates a reference type. The referenced type must contain a $id.

RegEx(regex: RegExp, options?: SchemaOptions): TString

Standard Creates a string type from a regular expression

Required<T extends TObject>(schema: T, options?: SchemaOptions): TRequired<T>

Standard Creates an object type whose properties are all required

ReturnType<T extends TFunction<any[], any>>(schema: T, options?: SchemaOptions): TReturnType<T>

Extended Creates a type from this functions return type

Strict<T extends TSchema>(schema: T): T

Removes Kind and Modifier symbol property keys from this schema

String<Format extends string>(options?: StringOptions<StringFormatOption | Format>): TString<Format>

Standard Creates a string type

Tuple<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TTuple<T>

Standard Creates a tuple type

Extended Creates a Uint8Array type

Extended Creates a undefined type

Union(items: [], options?: SchemaOptions): TNever

Standard Creates a union type

Union<T extends TSchema[]>(items: [...T], options?: SchemaOptions): TUnion<T>

Standard Creates a union type

Standard Creates an unknown type

Unsafe<T>(options?: UnsafeOptions): TUnsafe<T>

Standard Creates a user defined schema that infers as type T

Extended Creates a void type