From 9e79ea527d47988daabc9434f89415276b0f35fe Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Wed, 23 Sep 2026 13:48:00 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Infer=20parameter=20out?= =?UTF-8?q?puts=20from=20schemas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/param.ts | 15 ++++++++------- lib/types.ts | 6 +++++- 2 files changed, 13 insertions(+), 8 deletions(-) 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;