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
Type Parameters
PropertyAsserters extends Record<string, Asserter<unknown>>
Keys extends Array<keyof PropertyAsserters>