refine<T, S>Narrows the TypeScript type of a schema's output via a type guard predicate, attaching the guard as a runtime filter check.
Details
The annotations parameter annotates the filter created by the refinement.
With the default formatter, failed refinements use message first,
expected second, and <filter> when neither is provided. identifier
names type-level failures before the refinement runs; it does not name the
failed refinement itself.
export interface interface refine<T extends S["Type"], S extends Constraint>Narrows the TypeScript type of a schema's output via a type guard predicate,
attaching the guard as a runtime filter check.
Details
The annotations parameter annotates the filter created by the refinement.
With the default formatter, failed refinements use message first,
expected second, and <filter> when neither is provided. identifier
names type-level failures before the refinement runs; it does not name the
failed refinement itself.
Type-level representation returned by
refine
.
refine<function (type parameter) T in refine<T extends S["Type"], S extends Constraint>T extends function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["Type"], function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S extends Constraint> 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<
function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["ast"],
interface refine<T extends S["Type"], S extends Constraint>Narrows the TypeScript type of a schema's output via a type guard predicate,
attaching the guard as a runtime filter check.
Details
The annotations parameter annotates the filter created by the refinement.
With the default formatter, failed refinements use message first,
expected second, and <filter> when neither is provided. identifier
names type-level failures before the refinement runs; it does not name the
failed refinement itself.
Type-level representation returned by
refine
.
refine<function (type parameter) T in refine<T extends S["Type"], S extends Constraint>T, function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S>,
function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["~type.parameters"],
function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["~type.mutability"],
function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["~type.optionality"],
function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["~type.constructor.default"],
function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["~encoded.mutability"],
function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["~encoded.optionality"]
>
{
readonly "Type": function (type parameter) T in refine<T extends S["Type"], S extends Constraint>T
readonly "Encoded": function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["Encoded"]
readonly "DecodingServices": function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["DecodingServices"]
readonly "EncodingServices": function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["EncodingServices"]
readonly "~type.make.in": function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S["~type.make.in"]
readonly "~type.make": function (type parameter) T in refine<T extends S["Type"], S extends Constraint>T
readonly "Iso": function (type parameter) T in refine<T extends S["Type"], S extends Constraint>T
readonly refine<T extends S["Type"], S extends Constraint>.schema: S extends Constraintschema: function (type parameter) S in refine<T extends S["Type"], S extends Constraint>S
}
/**
* Narrows the TypeScript type of a schema's output via a type guard predicate,
* attaching the guard as a runtime filter check.
*
* **Details**
*
* The `annotations` parameter annotates the filter created by the refinement.
* With the default formatter, failed refinements use `message` first,
* `expected` second, and `<filter>` when neither is provided. `identifier`
* names type-level failures before the refinement runs; it does not name the
* failed refinement itself.
*
* @category filtering
* @since 3.10.0
*/
export function function refine<
S extends Constraint,
T extends S["Type"]
>(
refinement: (value: S["Type"]) => value is T,
annotations?: Annotations.Filter
): (schema: S) => refine<T, S>
Narrows the TypeScript type of a schema's output via a type guard predicate,
attaching the guard as a runtime filter check.
Details
The annotations parameter annotates the filter created by the refinement.
With the default formatter, failed refinements use message first,
expected second, and <filter> when neither is provided. identifier
names type-level failures before the refinement runs; it does not name the
failed refinement itself.
refine<function (type parameter) S in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>S extends Constraint, function (type parameter) T in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>T extends function (type parameter) S in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>S["Type"]>(
refinement: (value: S["Type"]) => value is Trefinement: (value: S["Type"]value: function (type parameter) S in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>S["Type"]) => value: S["Type"]value is function (type parameter) T in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>T,
annotations: Annotations.Filter | undefinedannotations?: Annotations.interface Annotations.FilterAnnotations for filter schema nodes (created via Schema.filter). Extends
Augment
with an optional error message, identifier, and metadata.
Filters are intentionally non-parametric to keep them covariant.
Filter
) {
return (schema: S extends Constraintschema: function (type parameter) S in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>S): interface refine<T extends S["Type"], S extends Constraint>Narrows the TypeScript type of a schema's output via a type guard predicate,
attaching the guard as a runtime filter check.
Details
The annotations parameter annotates the filter created by the refinement.
With the default formatter, failed refinements use message first,
expected second, and <filter> when neither is provided. identifier
names type-level failures before the refinement runs; it does not name the
failed refinement itself.
Type-level representation returned by
refine
.
refine<function (type parameter) T in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>T, function (type parameter) S in refine<S extends Constraint, T extends S["Type"]>(refinement: (value: S["Type"]) => value is T, annotations?: Annotations.Filter): (schema: S) => refine<T, S>S> =>
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 appendChecks<A extends AST>(
ast: A,
checks: Checks | undefined
): A
appendChecks(schema: S extends Constraintschema.Constraint["ast"]: SchemaAST.ASTast, [import SchemaASTSchemaAST.function makeFilterByGuard<
T extends E,
E
>(
is: (value: E) => value is T,
annotations?: Schema.Annotations.Filter
): Filter<any>
makeFilterByGuard(refinement: (value: S["Type"]) => value is Trefinement, annotations: Annotations.Filter | undefinedannotations)]), { schema: S extends Constraintschema })
}