Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/typebox/src/typebox.ts>JsonTypeBuilder

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

Methods

Any(options?: SchemaOptions): TAny

[Json] Creates an Any type

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

[Json] Creates an Array type

[Json] Creates a Boolean type

Capitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, "Capitalize">

[Json] Intrinsic function to Capitalize LiteralString types

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

[Json] Creates a Composite object type

Enum<V extends TEnumValue, T extends Record<TEnumKey, V>>(item: T, options?: SchemaOptions): TEnum<T>

[Json] Creates a Enum type

Exclude<L extends TSchema, R extends TSchema>(
unionType: L,
excludedMembers: R,
options?: SchemaOptions,
): TExclude<L, R>

[Json] Constructs a type by excluding from unionType all union members that are assignable to excludedMembers

Extends<L extends TSchema, R extends TSchema, T extends TSchema, U extends TSchema>(
left: L,
right: R,
trueType: T,
falseType: U,
options?: SchemaOptions,
): TExtends<L, R, T, U>

[Json] Creates a Conditional type

Extract<L extends TSchema, R extends TSchema>(
type: L,
union: R,
options?: SchemaOptions,
): TExtract<L, R>

[Json] Constructs a type by extracting from type all union members that are assignable to union

Index<T extends TArray, K extends TNumber>(
schema: T,
keys: K,
options?: SchemaOptions,
): AssertType<T["items"]>

[Json] Returns an Indexed property type for the given keys

Index<T extends TTuple, K extends (keyof Static<T>)[]>(
schema: T,
keys: [...K],
options?: SchemaOptions,
): TIndex<T, Assert<K, TPropertyKey[]>>

[Json] Returns an Indexed property type for the given keys

Index<T extends TTuple, K extends TNumber>(
schema: T,
keys: K,
options?: SchemaOptions,
): UnionType<AssertRest<T["items"]>>

[Json] Returns an Indexed property type for the given keys

Index<T extends TSchema, K extends TTemplateLiteral>(
schema: T,
keys: K,
options?: SchemaOptions,
): TIndex<T, TTemplateLiteralKeyRest<K>>

[Json] Returns an Indexed property type for the given keys

Index<T extends TSchema, K extends TLiteral<TPropertyKey>>(
schema: T,
keys: K,
options?: SchemaOptions,
): TIndex<T, [K["const"]]>

[Json] Returns an Indexed property type for the given keys

Index<T extends TSchema, K extends (keyof Static<T>)[]>(
schema: T,
keys: [...K],
options?: SchemaOptions,
): TIndex<T, Assert<K, TPropertyKey[]>>

[Json] Returns an Indexed property type for the given keys

Index<T extends TSchema, K extends TUnion<TLiteral<TPropertyKey>[]>>(
schema: T,
keys: K,
options?: SchemaOptions,
): TIndex<T, TUnionLiteralKeyRest<K>>

[Json] Returns an Indexed property type for the given keys

Index<T extends TSchema, K extends TSchema>(
schema: T,
key: K,
options?: SchemaOptions,
): TSchema

[Json] Returns an Indexed property type for the given keys

Integer(options?: NumericOptions<number>): TInteger

[Json] Creates an Integer type

Intersect(allOf: [], options?: SchemaOptions): TNever

[Json] Creates an Intersect type

Intersect<T extends [TSchema]>(allOf: [...T], options?: SchemaOptions): T[0]

[Json] Creates an Intersect type

Intersect<T extends TSchema[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>

[Json] Creates an Intersect type

KeyOf<T extends TSchema>(schema: T, options?: SchemaOptions): TKeyOf<T>

[Json] Creates a KeyOf type

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

[Json] Creates a Literal type

Lowercase<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, "Lowercase">

[Json] Intrinsic function to Lowercase LiteralString types

[Json] Creates a Never type

Not<T extends TSchema>(schema: T, options?: SchemaOptions): TNot<T>

[Json] Creates a Not type

[Json] Creates a Null type

Number(options?: NumericOptions<number>): TNumber

[Json] Creates a Number type

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

[Json] Creates an Object type

Omit<T extends TSchema, K extends (keyof Static<T>)[]>(
schema: T,
keys: readonly [...K],
options?: SchemaOptions,
): TOmit<T, K[number]>

[Json] Constructs a type whose keys are omitted from the given type

Omit<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(
schema: T,
keys: K,
options?: SchemaOptions,
): TOmit<T, TUnionLiteralKeyRest<K>[number]>

[Json] Constructs a type whose keys are omitted from the given type

Omit<T extends TSchema, K extends TLiteral<string>>(
schema: T,
key: K,
options?: SchemaOptions,
): TOmit<T, K["const"]>

[Json] Constructs a type whose keys are omitted from the given type

Omit<T extends TSchema, K extends TTemplateLiteral>(
schema: T,
key: K,
options?: SchemaOptions,
): TOmit<T, TTemplateLiteralKeyRest<K>[number]>

[Json] Constructs a type whose keys are omitted from the given type

Omit<T extends TSchema, K extends TNever>(
schema: T,
key: K,
options?: SchemaOptions,
): TOmit<T, never>

[Json] Constructs a type whose keys are omitted from the given type

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

[Json] Creates an Optional property

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

[Json] Constructs a type where all properties are optional

Pick<T extends TSchema, K extends (keyof Static<T>)[]>(
schema: T,
keys: readonly [...K],
options?: SchemaOptions,
): TPick<T, K[number]>

[Json] Constructs a type whose keys are picked from the given type

Pick<T extends TSchema, K extends TUnion<TLiteral<string>[]>>(
schema: T,
keys: K,
options?: SchemaOptions,
): TPick<T, TUnionLiteralKeyRest<K>[number]>

[Json] Constructs a type whose keys are picked from the given type

Pick<T extends TSchema, K extends TLiteral<string>>(
schema: T,
key: K,
options?: SchemaOptions,
): TPick<T, K["const"]>

[Json] Constructs a type whose keys are picked from the given type

Pick<T extends TSchema, K extends TTemplateLiteral>(
schema: T,
key: K,
options?: SchemaOptions,
): TPick<T, TTemplateLiteralKeyRest<K>[number]>

[Json] Constructs a type whose keys are picked from the given type

Pick<T extends TSchema, K extends TNever>(
schema: T,
key: K,
options?: SchemaOptions,
): TPick<T, never>

[Json] Constructs a type whose keys are picked from the given type

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

[Json] Creates a Readonly property

ReadonlyOptional<T extends TSchema>(schema: T): TReadonly<TOptional<T>>

[Json] Creates a Readonly and Optional property

Record<K extends TSchema, T extends TSchema>(
key: K,
schema: T,
options?: ObjectOptions,
): TRecordResolve<K, T>

[Json] Creates a Record type

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

[Json] Creates a Recursive type

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

[Json] Creates a Ref type. The referenced type must contain a $id

Ref<T extends TSchema>($ref: string, options?: SchemaOptions): TRef<T>

[Json] Creates a Ref type.

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

[Json] Constructs a type where all properties are required

Rest<T extends TSchema>(schema: T): TRest<T>

[Json] Extracts interior Rest elements from Tuple, Intersect and Union types

[Json] Creates a String type

TemplateLiteral<T extends string>(templateDsl: T, options?: SchemaOptions): TTemplateLiteralDslParser<T>

[Json] Creates a TemplateLiteral type from template dsl string

TemplateLiteral<T extends TTemplateLiteralKind[]>(kinds: [...T], options?: SchemaOptions): TTemplateLiteral<T>

[Json] Creates a TemplateLiteral type

Transform<I extends TSchema>(schema: I): TransformDecodeBuilder<I>

[Json] Creates a Transform type

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

[Json] Creates a Tuple type

Uncapitalize<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, "Uncapitalize">

[Json] Intrinsic function to Uncapitalize LiteralString types

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

[Json] Creates a Union type

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

[Json] Creates a Union type

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

[Json] Creates a Union type

Union<T extends TTemplateLiteral>(template: T): TUnionTemplateLiteral<T>

[Json-Experimental] Converts a TemplateLiteral into a Union

[Json] Creates an Unknown type

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

[Json] Creates a Unsafe type that will infers as the generic argument T

Uppercase<T extends TSchema>(schema: T, options?: SchemaOptions): TIntrinsic<T, "Uppercase">

[Json] Intrinsic function to Uppercase LiteralString types