import { Path, ParseResult } from './ParseResult' import { JsonSchema } from './JsonSchema' export type Refinement = (value: T) => boolean export type Refined = T & { readonly __r: { readonly [key in M]: never } } export type NonNull = Exclude export type Defined = Exclude export interface Parser { readonly descriptor: string readonly alias: string | null readonly isOptional: boolean readonly jsonSchema: JsonSchema parse(input: unknown, path?: Path): ParseResult is(input: unknown): input is T // TODO: https://github.com/microsoft/TypeScript/issues/34596 // assert(input: unknown): asserts input is T cast(input: unknown): T nullable(): Parser nonNullable(): Parser> optional(): Parser required(): Parser> refined( modifier: M, f: Refinement, ): Parser> aliased(alias: string): Parser }