Creates an IntersectionTypeGuard that checks that the value matches all provided type guards.
IntersectionTypeGuard
Can be shortened with TypeGuard.and.
TypeGuard.and
Best practice: use satisfies on the result of isIntersection to ensure the type guard is of the expected intersection type.
satisfies
isIntersection
Array of types in the intersection
The type guards for each type in the intersection
A type guard for the intersection of all the given type guards
type A = { a: number };type B = { b: string };type C = A & B;const isA = isType<A>({ a: isNumber });const isB = isType<B>({ b: isString });const isC = isIntersection(isA, isB) satisfies TypeGuard<C>; // or isA.and(isB)isC({ a: 1, b: "hello" }); // trueisC({ a: 1 }); // false Copy
type A = { a: number };type B = { b: string };type C = A & B;const isA = isType<A>({ a: isNumber });const isB = isType<B>({ b: isString });const isC = isIntersection(isA, isB) satisfies TypeGuard<C>; // or isA.and(isB)isC({ a: 1, b: "hello" }); // trueisC({ a: 1 }); // false
Creates an
IntersectionTypeGuardthat checks that the value matches all provided type guards.Can be shortened with
TypeGuard.and.Best practice: use
satisfieson the result ofisIntersectionto ensure the type guard is of the expected intersection type.