• P.not(pattern) returns a pattern which matches if the sub pattern doesn't match.

    Read the documentation for P.not on GitHub

    Type Parameters

    • input
    • const pattern extends undefined | null | string | number | bigint | boolean | symbol | readonly [] | readonly [unknown, unknown] | readonly [unknown, unknown] | {
          [k: string]: unknown;
      } | UnknownMatcher | readonly UnknownPattern[] | readonly [UnknownPattern, UnknownPattern] | readonly [UnknownPattern, UnknownPattern] | PatternMatcher<input> | {
          readonly [k in string | number | symbol]?: Pattern<Readonly<MergeUnion<Exclude<input, readonly any[] | Primitives | Map<any, any> | Set<any>>>>[k]>
      }

    Parameters

    Returns Chainable<NotP<input, pattern>>

    Example

    match<{ a: string | number }>(value)
    .with({ a: P.not(P.string) }, (x) => 'will match { a: number }'
    )