Skip to main content
Deno 2 is finally here 🎉️
Learn more
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.33.0/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>