Skip to main content
Module

x/typeguardkit/mod.ts>pick

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

pick can be used to create a PickAsserter without specifying a typeName.

Example:

import { _string, Asserted, ObjectAsserter, pick } 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 = pick(_User, ["firstName", "lastName"]);

export type UserName = Asserted<typeof _UserName>;

Type Parameters

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