[Home](../../readme.md) | [Installation](../installation.md) | [Usage](../usage.md) | **Types** | [Values](../values/) | [Syntax](../syntax/) | [TypeRegistry](../type-registry.md) | [TypeCheck](../type-check.md) # Unsafe Types TypeBox supports user defined types with Unsafe. This type allows you to specify both schema representation and inference type. The following creates an Unsafe type with a number schema that infers as string. ```typescript const T = Type.Unsafe({ type: "number" }); // const T = { type: 'number' } type T = Static; // type T = string - ? ``` The Unsafe type is often used to create schematics for extended specifications like OpenAPI. ```typescript const Nullable = (schema: T) => Type.Unsafe | null>({ ...schema, nullable: true, }); const T = Nullable(Type.String()); // const T = { // type: 'string', // nullable: true // } type T = Static; // type T = string | null const StringEnum = (values: [...T]) => Type.Unsafe({ type: "string", enum: values, }); const S = StringEnum(["A", "B", "C"]); // const S = { // enum: ['A', 'B', 'C'] // } type S = Static; // type S = 'A' | 'B' | 'C' ``` Back to [Home](../../readme.md)