Skip to main content
Module

x/typeguardkit/mod.ts>ObjectIntersectionAsserter

A TypeScript module to help construct type assertion functions and type guards.
Latest
Re-export
import { ObjectIntersectionAsserter } from "https://deno.land/x/typeguardkit@0.32.1/mod.ts";

An ObjectIntersectionAsserter is an ObjectAsserter for the intersection of the asserted types of the provided ObjectAsserters.

Example:

import {
  _string,
  Asserted,
  ObjectAsserter,
  ObjectIntersectionAsserter,
} from "typeguardkit";

// types/entity.ts

export const _Entity = new ObjectAsserter("Entity", {
  id: _string,
});

export type Entity = Asserted<typeof _Entity>;

// types/user.ts

export const _User = new ObjectIntersectionAsserter(
  "User",
  [
    _Entity,

    {
      name: _string,
    },
  ],
);

export type User = Asserted<typeof _User>;

Constructors

new
ObjectIntersectionAsserter(typeName: string, unnamed 1: [ObjectAsserter<PropertyAssertersA>, ObjectAsserter<PropertyAssertersB> | PropertyAssertersB])

Type Parameters

PropertyAssertersA extends Record<string, Asserter<unknown>>
PropertyAssertersB extends Record<string, Asserter<unknown>>