interface / @typed/router/Parser

Parser.OrElseWith

Binds a fallback Parser for later composition.

Package version
1.0.0-beta.7
Category
Parser composition
Since
1.0.0
Member of
Parser

Import

import { Parser } from "@typed/router/Parser";

Access Parser.OrElseWith through the imported Parser export. Its declaration below describes the member.

Signatures

interface OrElseWith<Q extends Any> extends TypeFunction {
    readonly return: InputOf<this> extends infer P extends Any ? OrElse<P, Q> : never;
}

Why

Reusable alternatives preserve the original-input fallback rule.

Ownership and lifetime

TypeScript instantiates OrElseWith while parsing a string-literal input; partial results and unconsumed text exist only in the resulting type.

Property: return

Computes this type lambda’s parse result for its current input.

Property: return: Why

The local type-function protocol evaluates each parser combinator through this member without a parallel runtime object.

Property: return: Ownership and lifetime

TypeScript evaluates OrElseWith.return when the surrounding parser is applied; the associated result is erased and retains no input at runtime.

Source