Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/typeguardkit/mod.ts>PickAsserter

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

A PickAsserter is an ObjectAsserter for the type constructed by picking the set of properties Keys from the asserted type of the provided ObjectAsserter.

Example:

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

// types/user.ts

export const _User = new ObjectAsserter("User", {
  id: _string,
  firstName: _string,
  lastName: _string,
});

export type User = Asserted<typeof _User>;

// types/user_name.ts

export const _UserName = new PickAsserter(
  "UserName",
  _User,
  ["firstName", "lastName"],
);

export type UserName = Asserted<typeof _UserName>;

Constructors

new
PickAsserter(
typeName: string,
keys: Keys,
)

Type Parameters

PropertyAsserters extends Record<string, Asserter<unknown>>
Keys extends Array<keyof PropertyAsserters>