diff --git a/lib/param.ts b/lib/param.ts index 271a4c9..59d75b4 100644 --- a/lib/param.ts +++ b/lib/param.ts @@ -8,7 +8,7 @@ import { type Unary, } from "./pipeline.ts"; import type { CLIBinding } from "./read.ts"; -import type { Definition, Schema } from "./types.ts"; +import type { Definition, OutputOf, Schema } from "./types.ts"; export interface Param extends Definition { schema: Schema; @@ -49,18 +49,19 @@ export function param< ) as Fold, E>; } -export function schema( - schema: Schema, -): TransformElement> { - return mark>((param: Param) => ({ +export function schema( + schema: S, +): TransformElement> { + return mark>((param: Param) => ({ ...param, schema, })); } -interface SchemaTransform extends Transform { +interface SchemaTransform extends Transform { readonly input: Param; - readonly output: this["input"] extends Param ? Param + readonly output: this["input"] extends Param + ? Param> : never; } diff --git a/lib/types.ts b/lib/types.ts index ef4b636..f04f3e2 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -6,7 +6,11 @@ import type { Result } from "./result.ts"; import type { ValueSource } from "./values.ts"; export type Issue = StandardSchemaV1.Issue; -export type Schema = StandardSchemaV1; +export type Schema = StandardSchemaV1< + Input, + Output +>; +export type OutputOf = StandardSchemaV1.InferOutput; export interface Definition { readonly name: N;