ConstReadonlyany: PAnyReadonlystring: PStringReadonlynumber: PNumberReadonlyboolean: PBooleanReadonlybigint: PBigintReadonlysymbol: PSymbolReadonlyfunction: PFunctionReadonlynullish: PNullishReadonlydefined: PDefinedReadonlynonNullable: PDefinedReadonlyarray: <Item>(item: Item) => PArray<Item>Readonlyunion: <const Values extends readonly unknown[]>(...values: Values) => PUnion<Values>Literal union — matches if the value is strictly equal (SameValue equality)
to any of the given values. Apply it on a discriminant field to narrow a
tagged union: { kind: P.union("a", "b") }.
Readonlywhen: <T>(fn: (v: T) => boolean) => PWhen<T>Arbitrary predicate — escape hatch when P.* doesn't cover your check.
Runs on every call; keep the predicate cheap (no allocation, no I/O) and
prefer narrower P.* when one applies.
Readonlynot: <Inner>(inner: Inner) => PNot<Inner>Readonlyoptional: <Inner>(inner: Inner) => POptional<Inner>Readonlyintersection: <const Parts extends readonly unknown[]>(Requires every sub-pattern to match the same value. Handy for layering
refinements: P.intersection(P.string, P.minLengthStr(3)).
ReadonlyinstanceOf: <C extends new (...args: never[]) => unknown>(ctor: C) => PInstanceOf<C>Readonlyregex: (re: RegExp) => PRegexReadonlystartsWithStr: (s: string) => PStartsWithStrReadonlyendsWithStr: (s: string) => PEndsWithStrReadonlyminLengthStr: (n: number) => PMinLengthStrReadonlymaxLengthStr: (n: number) => PMaxLengthStrReadonlylengthStr: (n: number) => PLengthStrReadonlyincludesStr: (s: string) => PIncludesStrReadonlybetween: (min: number, max: number) => PBetweenReadonlygt: (n: number) => PGtReadonlygte: (n: number) => PGteReadonlylt: (n: number) => PLtReadonlylte: (n: number) => PLteReadonlypositive: PPositiveReadonlynegative: PNegativeReadonlyinteger: PIntegerReadonlyfinite: PFiniteReadonlybigintGt: (n: bigint) => PBigintGtReadonlybigintGte: (n: bigint) => PBigintGteReadonlybigintLt: (n: bigint) => PBigintLtReadonlybigintLte: (n: bigint) => PBigintLteReadonlybigintBetween: (min: bigint, max: bigint) => PBigintBetweenReadonlybigintPositive: PBigintPositiveReadonlybigintNegative: PBigintNegativeReadonlytuple: <const Items extends readonly unknown[]>(...items: Items) => PTuple<Items>ReadonlystartsWith: <const Items extends readonly unknown[]>(...items: Items) => PStartsWith<Items>ReadonlyendsWith: <const Items extends readonly unknown[]>(...items: Items) => PEndsWith<Items>ReadonlyarrayOf: <Item>(item: Item, opts?: { min?: number; max?: number }) => PArrayOf<Item>ReadonlyarrayIncludes: <Item>(item: Item) => PArrayIncludes<Item>Readonlymap: <K, V>(key: K, value: V) => PMap<K, V>Readonlyset: <Item>(item: Item) => PSet<Item>Readonlyselect: {Extract the matched value into the handler. Overloads:
P.select() — extract the value at this position.P.select("label") — labelled extract; handler receives { [label]: ... }.P.select(subPattern) — extract only if subPattern also matches.P.select("label", subPattern) — labelled + refined.A lone string arg is treated as a label (ts-pattern convention). To match
a literal string and extract it, use P.intersection("literal", P.select()).
Pattern builders and sentinels. Use these inside a rule's
withto match by type, shape, refinement, or predicate.P.*calls allocate — keep patterns hoisted where possible so the compile-once design pays off.