Skip to content

Function: short()

WARNING

This API is experimental and may change in future versions.

Set a short alias on a combinator schema.

The original schema is not modified.

Signature

ts
declare function short<T, S extends string>(schema: CombinatorSchema<T>, alias: S): CombinatorSchema<T> & CombinatorShort<S>

Type Parameters

NameDescription
TThe schema's parsed type.
S extends stringThe short alias string literal type.

Parameters

NameTypeDescription
schemaCombinatorSchema<T>The base combinator schema.
aliasSSingle character short alias.

Returns

CombinatorSchema<T> & CombinatorShort<S> — A new schema with the short alias set.

Examples

ts
const args = {
  verbose: short(boolean(), 'v')
}
// Usage: -v or --verbose

Released under the MIT License.