Skip to content

Interface: Predicate()\<T, U\>

A callable predicate with fluent composition methods.

T is the accepted input type. U is the type established when the predicate returns true.

T

U extends T = T

Predicate(value): value is U

A callable predicate with fluent composition methods.

T is the accepted input type. U is the type established when the predicate returns true.

T

value is U

and<P>(…predicates): Predicate<T, Extract<U & AndNarrowed<U, P, U>, T>>

Returns a predicate requiring this predicate and every supplied predicate to match.

Type guards are intersected. Additional predicates are checked against the type already established by this predicate.

P extends readonly PredicateInput<U>[]

P

Predicate<T, Extract<U & AndNarrowed<U, P, U>, T>>


negate(): Predicate<T, Exclude<T, U>>

Returns the logical inverse of this predicate.

For a type predicate narrowing T to U, the result narrows to Exclude<T, U>.

Predicate<T, Exclude<T, U>>


or<P>(…predicates): Predicate<T, Extract<U, T> | Extract<OrNarrowed<U, P, never>, T>>

Returns a predicate requiring this predicate or any supplied predicate to match.

Type guards are unioned. Because an ordinary boolean predicate could accept any value of U, including one causes the resulting predicate to narrow only to U.

P extends readonly PredicateInput<U>[]

P

Predicate<T, Extract<U, T> | Extract<OrNarrowed<U, P, never>, T>>