import * as T from '@sinclair/typebox'; /** * ## {@link toType `box.toType`} * * Converts an arbitrary typebox schema into a string representing its underlying TypeScript type. * * @example * import * as vi from 'vitest' * import * as T from '@sinclair/typebox' * import { box } from '@traversable/typebox' * * vi.expect(box.toType( * T.Record(T.Enum({ a: 'A', b: 'B', c: 'C' }), T.Literal(1)) * )).toMatchInlineSnapshot * (`"{ A: 1, B: 1, C: 1 }"`) * * vi.expect(box.toType( * T.Intersect([T.Number(), T.Union([T.Literal(1), T.Literal(2), T.Literal(3)])]) * )).toMatchInlineSnapshot * (`"number & (1 | 2 | 3)"`) * * vi.expect(box.toType( * T.Object({ * x: T.Optional(T.Array(T.Number())), * y: T.Optional(T.Array(T.Number())), * z: T.Optional(T.Array(T.Number())), * }) * )).toMatchInlineSnapshot * (`"{ x?: Array, y?: Array, z?: Array }"`) * * // Use the `typeName` option to give you type a name: * vi.expect(box.toType( * T.Object({ a: T.Optional(T.Number()) }), * { typeName: 'MyType' } * )).toMatchInlineSnapshot * (`"type MyType = { a?: number }"`) */ export declare function toType(schematic: T.TSchema, options?: toType.Options): string; export declare function toType(schematic: Partial, options?: toType.Options): string; export declare namespace toType { export type { Options }; } declare const optionsWithInterface: { typeName: typeof optionsWithOptionalTypeName['typeName'] & {}; /** * ## {@link optionsWithInterface.preferInterface `toType.Options.preferInterface`} * * Use the `preferInterface` option to tell the compiler that you'd prefer the generated * type to be an interface, if possible. * * **Note:** This option has no effect unless you give you name a type via * {@link options.typeName `toType.Options.typeName`}. * * @example * console.log(box.toType(T.Object({ a: T.Number() }), { typeName: 'MyType' })) * // => type MyType = { a: number } * * console.log(box.toType(T.Object({ a: T.Number() }), { typeName: 'MyType', preferInterface: true })) * // => interface MyType { a: number } */ preferInterface: boolean; /** * ## {@link optionsWithInterface.includeNewtypeDeclaration `toType.Options.includeNewtypeDeclaration`} * * Default: true */ includeNewtypeDeclaration?: boolean; }; declare const optionsWithOptionalTypeName: { /** * ## {@link options.typeName `toType.Options.typeName`} * * Use `Options.typeName` to give you type a name. If no type name * is provided, the returned type will be anonymous. * * @example * console.log(box.toType(T.Number())) // => number * console.log(box.toType(T.Number(), { typeName: 'MyType' })) // => type MyType = number */ typeName?: string; }; declare const options: typeof optionsWithInterface | typeof optionsWithOptionalTypeName; export type Options = typeof options; export {}; //# sourceMappingURL=to-type.d.ts.map