Skip to content

Infer

@tsed/schema

Usage

typescript
import { Infer } from "@tsed/specs/schema/src/domain/types";

See /packages/specs/schema/src/domain/types.ts.

Overview

ts
type Infer<S> = S extends JsonSchema<infer T> ? T : never;

Description

Extracts the inferred TypeScript type from a JsonSchema.

This utility type enables type-safe schema usage by extracting the type parameter from JsonSchema instances.

Usage

typescript
const userSchema = JsonSchema.from({ type: "object" });
type User = Infer<typeof userSchema>; // Extracts the type

Released under the MIT License.