PropsToShape
@tsed/schema
Usage
typescript
import { PropsToShape } from "@tsed/specs/schema/src/domain/types";Overview
ts
type PropsToShape<P extends Record<string, JsonSchema<any>>> = {
[K in keyof P]: Infer<P[K]>;
};Description
Maps an object of JsonSchema properties to a concrete TypeScript type.
Converts a record of JsonSchema properties into a TypeScript type where each property has the inferred type from its corresponding schema.
Usage
typescript
const properties = {
name: string(),
age: number(),
email: string().format("email")
};
type Shape = PropsToShape<typeof properties>;
// Result: { name: string; age: number; email: string }[K in keyof P]
ts
[K in keyof P]: Infer<P[K]>;