interface / @typed/router/Parser

Parser.String

Consumes one exact leading string literal.

Package version
1.0.0-beta.13
Category
Parser primitives
Since
1.0.0
Member of
Parser

Import

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

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

Signatures

interface String<S extends string> extends TypeFunction<string, Result<S, string>> {
    readonly return: InputOf<this> extends `${S}${infer Rest}` ? readonly [
        S,
        Rest
    ] : never;
}

Why

Multi-character tokens remain atomic in composed grammars.

Ownership and lifetime

TypeScript recursively instantiates TakeWhileInternal while characters remain allowed. Its accumulator and remainder are erased after type checking.

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 String.return when the surrounding parser is applied; the associated result is erased and retains no input at runtime.

Source