Import
import { GuardType } from "@typed/router";This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.
Signatures
export type GuardType<in I, out O, out E = never, out R = never> = (input: I) => Effect.Effect<Option.Option<O>, E, R>;export declare namespace GuardType {
type Input<T> = [
T
] extends [
Guard<infer I, infer _R, infer _E, infer _O>
] ? I : [
T
] extends [
AsGuard<infer I, infer _R, infer _E, infer _O>
] ? I : never;
type Services<T> = [
T
] extends [
Guard<infer _I, infer _O, infer _E, infer R>
] ? R : [
T
] extends [
AsGuard<infer _I, infer _O, infer _E, infer R>
] ? R : never;
type Error<T> = [
T
] extends [
Guard<infer _I, infer _O, infer E, infer _R>
] ? E : [
T
] extends [
AsGuard<infer _I, infer _O, infer E, infer _R>
] ? E : never;
type Output<T> = [
T
] extends [
Guard<infer _I, infer O, infer _E, infer _R>
] ? O : [
T
] extends [
AsGuard<infer _I, infer O, infer _E, infer _R>
] ? O : never;
}Why
Guard models non-match as successful None, keeping ordinary dispatch separate from typed failure, defects, and interruption in Effect’s Cause.
Ownership and lifetime
A Guard acquires no resources by itself; each invocation has the lifetime and service requirements of the returned Effect.
See Effect Option and Effect error management.
Examples
import type { Guard } from "@typed/guard"
import { Effect, Option } from "effect"
const string: Guard<unknown, string> = (input) => Effect.succeed(typeof input === "string" ? Option.some(input) : Option.none())Members
GuardType.ErrorExtracts the typed error channel from a Guard or Guard adapter.
GuardType.InputExtracts the accepted input type from a Guard or Guard adapter.
GuardType.OutputExtracts the matched output type from a Guard or Guard adapter.
GuardType.ServicesExtracts the Effect service requirements from a Guard or Guard adapter.
Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.