TupleWithRest<S, Rest>Extends a fixed-length tuple schema with a variadic rest segment.
Details
The resulting tuple starts with the fixed elements from schema. The first
schema in rest is the repeatable element schema, and any additional schemas
in rest are required trailing tuple elements after the variadic segment. For
example, [Schema.Boolean, Schema.String] represents zero or more booleans
followed by a final string.
Example (Defining tuples with rest elements)
import { Schema } from "effect"
// [string, number, ...boolean[]]
const schema = Schema.TupleWithRest(
Schema.Tuple([Schema.String, Schema.Number]),
[Schema.Boolean]
)
const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
console.log(result)
// [ 'hello', 1, true, false ]export declare namespace TupleWithRest {
/**
* Constraint for tuple-like schemas that can be used as the fixed leading
* portion of a `TupleWithRest` schema.
*
* @category utility types
* @since 3.10.0
*/
export type type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.TupleType = Constraint & {
readonly Type: ReadonlyArray<unknown>;
readonly Encoded: ReadonlyArray<unknown>;
readonly ast: SchemaAST.Arrays;
readonly "~type.make": ReadonlyArray<unknown>;
readonly Iso: ReadonlyArray<unknown>;
}
Constraint for tuple-like schemas that can be used as the fixed leading
portion of a TupleWithRest schema.
TupleType = Constraint & {
readonly type Type: readonly unknown[]Type: interface ReadonlyArray<T>ReadonlyArray<unknown>
readonly type Encoded: readonly unknown[]Encoded: interface ReadonlyArray<T>ReadonlyArray<unknown>
readonly ast: SchemaAST.Arrays(property) ast: {
_tag: 'Arrays';
isMutable: boolean;
elements: ReadonlyArray<AST>;
rest: ReadonlyArray<AST>;
encodingChecks: Checks | undefined;
getParser: (recur: (ast: AST) => SchemaParser.Parser) => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Arrays;
recur: (recur: (ast: AST) => AST) => Arrays;
flip: (recur: (ast: AST) => AST) => Arrays;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast: import SchemaASTSchemaAST.class Arraysclass Arrays {
_tag: 'Arrays';
isMutable: boolean;
elements: ReadonlyArray<AST>;
rest: ReadonlyArray<AST>;
encodingChecks: Checks | undefined;
getParser: (recur: (ast: AST) => SchemaParser.Parser) => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Arrays;
recur: (recur: (ast: AST) => AST) => Arrays;
flip: (recur: (ast: AST) => AST) => Arrays;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for array-like types — both tuples and arrays.
When to use
Use when constructing or inspecting AST nodes for tuple or array-like schemas,
including rest elements.
Details
elements — positional element types (tuple elements). An element is
optional if its
Context.isOptional
is true.
rest — the rest/variadic element types. When non-empty, the first
entry is the "spread" type (e.g. ...Array<string>), and subsequent
entries are trailing positional elements after the spread.
isMutable — whether the resulting array is readonly (false) or
mutable (true).
Gotchas
Construction enforces TypeScript ordering rules: a required element
cannot follow an optional one, and an optional element cannot follow a
rest element.
Example (Inspecting a tuple AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Tuple([Schema.String, Schema.Number])
const ast = schema.ast
if (SchemaAST.isArrays(ast)) {
console.log(ast.elements.length) // 2
console.log(ast.rest.length) // 0
}
Arrays
readonly "~type.make": interface ReadonlyArray<T>ReadonlyArray<unknown>
readonly "Iso": interface ReadonlyArray<T>ReadonlyArray<unknown>
}
/**
* Non-empty list of schemas used for the rest portion of a `TupleWithRest`.
*
* **Details**
*
* The first schema describes the repeated rest element. Additional schemas, when
* present, describe trailing tuple elements after the repeated rest segment.
*
* @category utility types
* @since 3.10.0
*/
export type type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Rest = readonly [Constraint, ...Constraint[]]Non-empty list of schemas used for the rest portion of a TupleWithRest.
Details
The first schema describes the repeated rest element. Additional schemas, when
present, describe trailing tuple elements after the repeated rest segment.
Rest = readonly [Constraint, ...interface Array<T>Array<Constraint>]
/**
* Computes the decoded tuple type for a `TupleWithRest`.
*
* **Details**
*
* The output starts with the fixed tuple elements, continues with zero or more
* values decoded by the first rest schema, and includes any trailing rest schemas
* as fixed tuple positions.
*
* @category utility types
* @since 3.10.0
*/
export type type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...Readonly<T>, ...Head["Type"][], ...Readonly<{ readonly [K in keyof Tail]: Tail[K]["Type"]; }>] : TComputes the decoded tuple type for a TupleWithRest.
Details
The output starts with the fixed tuple elements, continues with zero or more
values decoded by the first rest schema, and includes any trailing rest schemas
as fixed tuple positions.
Type<function (type parameter) T in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>T extends interface ReadonlyArray<T>ReadonlyArray<unknown>, function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Rest = readonly [Constraint, ...Constraint[]]Non-empty list of schemas used for the rest portion of a TupleWithRest.
Details
The first schema describes the repeated rest element. Additional schemas, when
present, describe trailing tuple elements after the repeated rest segment.
Rest> = function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends
readonly [infer function (type parameter) HeadHead extends Constraint, ...infer function (type parameter) TailTail extends interface ReadonlyArray<T>ReadonlyArray<Constraint>] ? type Readonly<T> = {
readonly [P in keyof T]: T[P]
}
Make all properties in T readonly
Readonly<[
...function (type parameter) T in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>T,
...interface Array<T>Array<function (type parameter) HeadHead["Type"]>,
...{ readonly [function (type parameter) KK in keyof function (type parameter) TailTail]: function (type parameter) TailTail[function (type parameter) KK]["Type"] }
]> :
function (type parameter) T in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>T
/**
* Computes the iso tuple type for a `TupleWithRest`.
*
* **Details**
*
* The output starts with the fixed tuple's `Iso` elements, continues with zero
* or more values using the first rest schema's `Iso`, and includes any trailing
* rest schemas as fixed tuple positions.
*
* @category utility types
* @since 4.0.0
*/
export type type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...Readonly<T>, ...Head["Iso"][], ...Readonly<{ readonly [K in keyof Tail]: Tail[K]["Iso"]; }>] : TComputes the iso tuple type for a TupleWithRest.
Details
The output starts with the fixed tuple's Iso elements, continues with zero
or more values using the first rest schema's Iso, and includes any trailing
rest schemas as fixed tuple positions.
Iso<function (type parameter) T in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>T extends interface ReadonlyArray<T>ReadonlyArray<unknown>, function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Rest = readonly [Constraint, ...Constraint[]]Non-empty list of schemas used for the rest portion of a TupleWithRest.
Details
The first schema describes the repeated rest element. Additional schemas, when
present, describe trailing tuple elements after the repeated rest segment.
Rest> = function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends
readonly [infer function (type parameter) HeadHead extends Constraint, ...infer function (type parameter) TailTail extends interface ReadonlyArray<T>ReadonlyArray<Constraint>] ? type Readonly<T> = {
readonly [P in keyof T]: T[P]
}
Make all properties in T readonly
Readonly<[
...function (type parameter) T in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>T,
...interface Array<T>Array<function (type parameter) HeadHead["Iso"]>,
...{ readonly [function (type parameter) KK in keyof function (type parameter) TailTail]: function (type parameter) TailTail[function (type parameter) KK]["Iso"] }
]> :
function (type parameter) T in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>T
/**
* Computes the encoded tuple type for `TupleWithRest`.
*
* **Details**
*
* The leading tuple's encoded elements are kept first. The encoded type of the
* first rest schema may repeat zero or more times, and the encoded types of any
* additional rest schemas become required trailing tuple elements.
*
* @category utility types
* @since 3.10.0
*/
export type type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...E, ...Head["Encoded"][], ...{ readonly [K in keyof Tail]: Tail[K]["Encoded"]; }] : EComputes the encoded tuple type for TupleWithRest.
Details
The leading tuple's encoded elements are kept first. The encoded type of the
first rest schema may repeat zero or more times, and the encoded types of any
additional rest schemas become required trailing tuple elements.
Encoded<function (type parameter) E in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>E extends interface ReadonlyArray<T>ReadonlyArray<unknown>, function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Rest = readonly [Constraint, ...Constraint[]]Non-empty list of schemas used for the rest portion of a TupleWithRest.
Details
The first schema describes the repeated rest element. Additional schemas, when
present, describe trailing tuple elements after the repeated rest segment.
Rest> = function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends
readonly [infer function (type parameter) HeadHead extends Constraint, ...infer function (type parameter) TailTail extends interface ReadonlyArray<T>ReadonlyArray<Constraint>] ? readonly [
...function (type parameter) E in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>E,
...interface Array<T>Array<function (type parameter) HeadHead["Encoded"]>,
...{ readonly [function (type parameter) KK in keyof function (type parameter) TailTail]: function (type parameter) TailTail[function (type parameter) KK]["Encoded"] }
] :
function (type parameter) E in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>E
/**
* Computes the constructor input tuple type for `TupleWithRest`.
*
* **Details**
*
* The leading tuple's make input elements are kept first. The make input type of
* the first rest schema may repeat zero or more times, and the make input types
* of any additional rest schemas become required trailing tuple elements.
*
* @category utility types
* @since 4.0.0
*/
export type type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...M, ...Head["~type.make"][], ...{ readonly [K in keyof Tail]: Tail[K]["~type.make"]; }] : MComputes the constructor input tuple type for TupleWithRest.
Details
The leading tuple's make input elements are kept first. The make input type of
the first rest schema may repeat zero or more times, and the make input types
of any additional rest schemas become required trailing tuple elements.
MakeIn<function (type parameter) M in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>M extends interface ReadonlyArray<T>ReadonlyArray<unknown>, function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Rest = readonly [Constraint, ...Constraint[]]Non-empty list of schemas used for the rest portion of a TupleWithRest.
Details
The first schema describes the repeated rest element. Additional schemas, when
present, describe trailing tuple elements after the repeated rest segment.
Rest> = function (type parameter) Rest in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>Rest extends
readonly [infer function (type parameter) HeadHead extends Constraint, ...infer function (type parameter) TailTail extends interface ReadonlyArray<T>ReadonlyArray<Constraint>] ? readonly [
...function (type parameter) M in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>M,
...interface Array<T>Array<function (type parameter) HeadHead["~type.make"]>,
...{ readonly [function (type parameter) KK in keyof function (type parameter) TailTail]: function (type parameter) TailTail[function (type parameter) KK]["~type.make"] }
] :
function (type parameter) M in type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest>M
}
/**
* Type-level representation returned by {@link TupleWithRest}.
*
* @category models
* @since 4.0.0
*/
export interface interface TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Extends a fixed-length tuple schema with a variadic rest segment.
Details
The resulting tuple starts with the fixed elements from schema. The first
schema in rest is the repeatable element schema, and any additional schemas
in rest are required trailing tuple elements after the variadic segment. For
example, [Schema.Boolean, Schema.String] represents zero or more booleans
followed by a final string.
Example (Defining tuples with rest elements)
import { Schema } from "effect"
// [string, number, ...boolean[]]
const schema = Schema.TupleWithRest(
Schema.Tuple([Schema.String, Schema.Number]),
[Schema.Boolean]
)
const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
console.log(result)
// [ 'hello', 1, true, false ]
Namespace for TupleWithRest type utilities.
Details
TupleWithRest.TupleType — constraint for the leading tuple schema
TupleWithRest.Rest — the rest element schema(s)
TupleWithRest.Type<T, R> — decoded type (fixed elements + rest)
TupleWithRest.Encoded<T, R> — encoded type
Type-level representation returned by
TupleWithRest
.
TupleWithRest<
function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S extends TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.TupleType = Constraint & {
readonly Type: ReadonlyArray<unknown>;
readonly Encoded: ReadonlyArray<unknown>;
readonly ast: SchemaAST.Arrays;
readonly "~type.make": ReadonlyArray<unknown>;
readonly Iso: ReadonlyArray<unknown>;
}
Constraint for tuple-like schemas that can be used as the fixed leading
portion of a TupleWithRest schema.
TupleType,
function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest extends TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Rest = readonly [Constraint, ...Constraint[]]Non-empty list of schemas used for the rest portion of a TupleWithRest.
Details
The first schema describes the repeated rest element. Additional schemas, when
present, describe trailing tuple elements after the repeated rest segment.
Rest
> extends
interface BottomLazy<out Ast extends SchemaAST.AST, out Rebuild extends Top, in out TypeParameters extends ReadonlyArray<Constraint> = readonly [], out TypeMutability extends Mutability = "readonly", out TypeOptionality extends Optionality = "required", out TypeConstructorDefault extends ConstructorDefault = "no-default", out EncodedMutability extends Mutability = "readonly", out EncodedOptionality extends Optionality = "required">Lazy Bottom variant for schema implementations that compute their public
views on demand.
When to use
Use as an implementation base for schema interfaces that must expose
Bottom behavior without forcing TypeScript to eagerly evaluate expensive
Type, Encoded, or service views.
Details
The laziness is purely type-level; runtime behavior is unchanged.
BottomLazy keeps the structural operations inherited from Bottom, but
erases the expensive schema views to unknown. Concrete schema interfaces can
then redeclare the precise views they expose. This keeps wide schemas such as
Struct and Union cheaper when generic code reads a single view, while
preserving their exact public types.
BottomLazy<
import SchemaASTSchemaAST.class Arraysclass Arrays {
_tag: 'Arrays';
isMutable: boolean;
elements: ReadonlyArray<AST>;
rest: ReadonlyArray<AST>;
encodingChecks: Checks | undefined;
getParser: (recur: (ast: AST) => SchemaParser.Parser) => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Arrays;
recur: (recur: (ast: AST) => AST) => Arrays;
flip: (recur: (ast: AST) => AST) => Arrays;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
AST node for array-like types — both tuples and arrays.
When to use
Use when constructing or inspecting AST nodes for tuple or array-like schemas,
including rest elements.
Details
elements — positional element types (tuple elements). An element is
optional if its
Context.isOptional
is true.
rest — the rest/variadic element types. When non-empty, the first
entry is the "spread" type (e.g. ...Array<string>), and subsequent
entries are trailing positional elements after the spread.
isMutable — whether the resulting array is readonly (false) or
mutable (true).
Gotchas
Construction enforces TypeScript ordering rules: a required element
cannot follow an optional one, and an optional element cannot follow a
rest element.
Example (Inspecting a tuple AST)
import { Schema, SchemaAST } from "effect"
const schema = Schema.Tuple([Schema.String, Schema.Number])
const ast = schema.ast
if (SchemaAST.isArrays(ast)) {
console.log(ast.elements.length) // 2
console.log(ast.rest.length) // 0
}
Arrays,
interface TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Extends a fixed-length tuple schema with a variadic rest segment.
Details
The resulting tuple starts with the fixed elements from schema. The first
schema in rest is the repeatable element schema, and any additional schemas
in rest are required trailing tuple elements after the variadic segment. For
example, [Schema.Boolean, Schema.String] represents zero or more booleans
followed by a final string.
Example (Defining tuples with rest elements)
import { Schema } from "effect"
// [string, number, ...boolean[]]
const schema = Schema.TupleWithRest(
Schema.Tuple([Schema.String, Schema.Number]),
[Schema.Boolean]
)
const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
console.log(result)
// [ 'hello', 1, true, false ]
Namespace for TupleWithRest type utilities.
Details
TupleWithRest.TupleType — constraint for the leading tuple schema
TupleWithRest.Rest — the rest element schema(s)
TupleWithRest.Type<T, R> — decoded type (fixed elements + rest)
TupleWithRest.Encoded<T, R> — encoded type
Type-level representation returned by
TupleWithRest
.
TupleWithRest<function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S, function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest>
>
{
readonly "Type": TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Type<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...Readonly<T>, ...Head["Type"][], ...Readonly<{ readonly [K in keyof Tail]: Tail[K]["Type"]; }>] : TComputes the decoded tuple type for a TupleWithRest.
Details
The output starts with the fixed tuple elements, continues with zero or more
values decoded by the first rest schema, and includes any trailing rest schemas
as fixed tuple positions.
Type<function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S["Type"], function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest>
readonly "Encoded": TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Encoded<E extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...E, ...Head["Encoded"][], ...{ readonly [K in keyof Tail]: Tail[K]["Encoded"]; }] : EComputes the encoded tuple type for TupleWithRest.
Details
The leading tuple's encoded elements are kept first. The encoded type of the
first rest schema may repeat zero or more times, and the encoded types of any
additional rest schemas become required trailing tuple elements.
Encoded<function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S["Encoded"], function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest>
readonly "DecodingServices": function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S["DecodingServices"] | function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest[number]["DecodingServices"]
readonly "EncodingServices": function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S["EncodingServices"] | function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest[number]["EncodingServices"]
readonly "~type.make.in": TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...M, ...Head["~type.make"][], ...{ readonly [K in keyof Tail]: Tail[K]["~type.make"]; }] : MComputes the constructor input tuple type for TupleWithRest.
Details
The leading tuple's make input elements are kept first. The make input type of
the first rest schema may repeat zero or more times, and the make input types
of any additional rest schemas become required trailing tuple elements.
MakeIn<function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S["~type.make"], function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest>
readonly "~type.make": TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.MakeIn<M extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...M, ...Head["~type.make"][], ...{ readonly [K in keyof Tail]: Tail[K]["~type.make"]; }] : MComputes the constructor input tuple type for TupleWithRest.
Details
The leading tuple's make input elements are kept first. The make input type of
the first rest schema may repeat zero or more times, and the make input types
of any additional rest schemas become required trailing tuple elements.
MakeIn<function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S["~type.make"], function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest>
readonly "Iso": TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Iso<T extends ReadonlyArray<unknown>, Rest extends TupleWithRest.Rest> = Rest extends readonly [infer Head extends Constraint, ...infer Tail extends readonly Constraint[]] ? readonly [...Readonly<T>, ...Head["Iso"][], ...Readonly<{ readonly [K in keyof Tail]: Tail[K]["Iso"]; }>] : TComputes the iso tuple type for a TupleWithRest.
Details
The output starts with the fixed tuple's Iso elements, continues with zero
or more values using the first rest schema's Iso, and includes any trailing
rest schemas as fixed tuple positions.
Iso<function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S["Iso"], function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest>
readonly TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.schema: S extends TupleWithRest.TupleTypeschema: function (type parameter) S in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>S
readonly TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.rest: Rest extends TupleWithRest.Restrest: function (type parameter) Rest in TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Rest
}
/**
* Extends a fixed-length tuple schema with a variadic rest segment.
*
* **Details**
*
* The resulting tuple starts with the fixed elements from `schema`. The first
* schema in `rest` is the repeatable element schema, and any additional schemas
* in `rest` are required trailing tuple elements after the variadic segment. For
* example, `[Schema.Boolean, Schema.String]` represents zero or more booleans
* followed by a final string.
*
* **Example** (Defining tuples with rest elements)
*
* ```ts
* import { Schema } from "effect"
*
* // [string, number, ...boolean[]]
* const schema = Schema.TupleWithRest(
* Schema.Tuple([Schema.String, Schema.Number]),
* [Schema.Boolean]
* )
*
* const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
* console.log(result)
* // [ 'hello', 1, true, false ]
* ```
*
* @category constructors
* @since 4.0.0
*/
export function function TupleWithRest<
S extends Tuple<Tuple.Elements>,
Rest extends TupleWithRest.Rest
>(schema: S, rest: Rest): TupleWithRest<S, Rest>
Extends a fixed-length tuple schema with a variadic rest segment.
Details
The resulting tuple starts with the fixed elements from schema. The first
schema in rest is the repeatable element schema, and any additional schemas
in rest are required trailing tuple elements after the variadic segment. For
example, [Schema.Boolean, Schema.String] represents zero or more booleans
followed by a final string.
Example (Defining tuples with rest elements)
import { Schema } from "effect"
// [string, number, ...boolean[]]
const schema = Schema.TupleWithRest(
Schema.Tuple([Schema.String, Schema.Number]),
[Schema.Boolean]
)
const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
console.log(result)
// [ 'hello', 1, true, false ]
TupleWithRest<function (type parameter) S in TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extends TupleWithRest.Rest>(schema: S, rest: Rest): TupleWithRest<S, Rest>S extends interface Tuple<Elements extends Tuple.Elements>Defines a fixed-length tuple schema from an array of element schemas.
Example (Defining a pair of string and number)
import { Schema } from "effect"
const schema = Schema.Tuple([Schema.String, Schema.Number])
const pair = Schema.decodeUnknownSync(schema)(["hello", 42])
console.log(pair)
// [ 'hello', 42 ]
Namespace for Tuple type utilities.
Details
Tuple.Elements — constraint for the element schema array
Tuple.Type<E> — decoded tuple type
Tuple.Encoded<E> — encoded tuple type
Tuple.MakeIn<E> — constructor input tuple
Type-level representation returned by
Tuple
.
Tuple<Tuple.type Tuple<Elements extends Tuple.Elements>.Elements = readonly Constraint[]Constraint for the readonly array of element schemas used to define a
fixed-length Tuple schema.
Elements>, const function (type parameter) Rest in TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extends TupleWithRest.Rest>(schema: S, rest: Rest): TupleWithRest<S, Rest>Rest extends TupleWithRest.type TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>.Rest = readonly [Constraint, ...Constraint[]]Non-empty list of schemas used for the rest portion of a TupleWithRest.
Details
The first schema describes the repeated rest element. Additional schemas, when
present, describe trailing tuple elements after the repeated rest segment.
Rest>(
schema: S extends Tuple<Tuple.Elements>schema: function (type parameter) S in TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extends TupleWithRest.Rest>(schema: S, rest: Rest): TupleWithRest<S, Rest>S,
rest: const Rest extends TupleWithRest.Restrest: function (type parameter) Rest in TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extends TupleWithRest.Rest>(schema: S, rest: Rest): TupleWithRest<S, Rest>Rest
): interface TupleWithRest<S extends TupleWithRest.TupleType, Rest extends TupleWithRest.Rest>Extends a fixed-length tuple schema with a variadic rest segment.
Details
The resulting tuple starts with the fixed elements from schema. The first
schema in rest is the repeatable element schema, and any additional schemas
in rest are required trailing tuple elements after the variadic segment. For
example, [Schema.Boolean, Schema.String] represents zero or more booleans
followed by a final string.
Example (Defining tuples with rest elements)
import { Schema } from "effect"
// [string, number, ...boolean[]]
const schema = Schema.TupleWithRest(
Schema.Tuple([Schema.String, Schema.Number]),
[Schema.Boolean]
)
const result = Schema.decodeUnknownSync(schema)(["hello", 1, true, false])
console.log(result)
// [ 'hello', 1, true, false ]
Namespace for TupleWithRest type utilities.
Details
TupleWithRest.TupleType — constraint for the leading tuple schema
TupleWithRest.Rest — the rest element schema(s)
TupleWithRest.Type<T, R> — decoded type (fixed elements + rest)
TupleWithRest.Encoded<T, R> — encoded type
Type-level representation returned by
TupleWithRest
.
TupleWithRest<function (type parameter) S in TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extends TupleWithRest.Rest>(schema: S, rest: Rest): TupleWithRest<S, Rest>S, function (type parameter) Rest in TupleWithRest<S extends Tuple<Tuple.Elements>, const Rest extends TupleWithRest.Rest>(schema: S, rest: Rest): TupleWithRest<S, Rest>Rest> {
return const make: <S extends Constraint>(
ast: S["ast"],
options?: object
) => S
Creates a schema from an AST (Abstract Syntax Tree) node.
Details
This is the fundamental constructor for all schemas in the Effect Schema
library. It takes an AST node and wraps it in a fully-typed schema that
preserves all type information and provides the complete schema API.
The make function is used internally to create all primitive schemas like
String, Number, Boolean, etc., as well as more complex schemas. It's
the bridge between the untyped AST representation and the strongly-typed
schema.
make(import SchemaASTSchemaAST.function tupleWithRest(
ast: Arrays,
rest: ReadonlyArray<AST>
): Arrays
tupleWithRest(schema: S extends Tuple<Tuple.Elements>schema.Bottom<unknown, unknown, unknown, unknown, Arrays, Tuple<Tuple<Elements extends Tuple.Elements>.Elements>, unknown, unknown, readonly [], unknown, "readonly", "required", "no-default", "readonly", "required">["ast"]: SchemaAST.Arrays(property) Bottom<unknown, unknown, unknown, unknown, Arrays, Tuple<Tuple<Elements extends Tuple.Elements>.Elements>, unknown, unknown, readonly [], unknown, "readonly", "required", "no-default", "readonly", "required">["ast"]: {
_tag: 'Arrays';
isMutable: boolean;
elements: ReadonlyArray<AST>;
rest: ReadonlyArray<AST>;
encodingChecks: Checks | undefined;
getParser: (recur: (ast: AST) => SchemaParser.Parser) => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Arrays;
recur: (recur: (ast: AST) => AST) => Arrays;
flip: (recur: (ast: AST) => AST) => Arrays;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, rest: const Rest extends TupleWithRest.Restrest.ReadonlyArray<Constraint>.map<SchemaAST.AST>(callbackfn: (value: Constraint, index: number, array: readonly Constraint[]) => SchemaAST.AST, thisArg?: any): SchemaAST.AST[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(import SchemaASTSchemaAST.function getAST<
S extends { readonly ast: AST }
>(self: S): S["ast"]
getAST)), { schema: S extends Tuple<Tuple.Elements>schema, rest: const Rest extends TupleWithRest.Restrest })
}