interface / @typed/router

AsGuard

An object that supplies a Guard through an own callable asGuard property. Use an instance field rather than a prototype method.

Package version
1.0.0-beta.7
Category
Guard contracts
Since
1.0.0

Import

import { AsGuard } 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 interface AsGuard<in I, out O, out E = never, out R = never> {
    readonly asGuard: () => Guard<I, O, E, R>;
}

Why

An explicit adapter protocol lets domain objects participate in Guard composition without inheritance or wrapper allocation.

Ownership and lifetime

The adapter acquires no resources; the returned Guard owns no lifetime beyond each returned Effect.

Property: asGuard

Returns the Guard represented by this adapter.

Property: asGuard: Why

Requiring an own callable property avoids ambiguous prototype behavior when adapters cross object boundaries.

Property: asGuard: Ownership and lifetime

Calling this property acquires no resources; the returned Guard follows its own Effect lifetime.

Examples

import type { AsGuard, Guard } from "@typed/guard"
import { Effect } from "effect"
const adapter: AsGuard<string, string> = { asGuard: () => ((input) => Effect.succeedSome(input)) as Guard<string, string> }

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source