Skip to main content
Module

x/typeguardkit/mod.ts>objectIntersection

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

objectIntersection can be used to create an ObjectIntersectionAsserter without specifying a typeName.

Example:

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

// types/a.ts

export const _A = new ObjectAsserter("A", {
  a: _string,
});

export type A = Asserted<typeof _A>;

// types/b.ts

export const _B = new ObjectAsserter("B", {
  b: _string,
});

export type B = Asserted<typeof _B>;

// types/c.ts

export const _C = objectIntersection(_A, _B);

export type C = Asserted<typeof _C>;

Type Parameters

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