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

x/typeguardkit/mod.ts>RecordAsserter

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

A RecordAsserter is an Asserter for the Record type defined by its keyAsserter and valueAsserter.

The provided keyAsserter and valueAsserter are made accessible as properties of the created RecordAsserter.

The record function can be used to create a RecordAsserter without specifying a typeName.

Example:

import { _string, Asserted, RecordAsserter } from "typeguardkit";

export const _RecordOfStringByString = new RecordAsserter(
  "RecordOfStringByString",
  [_string, _string],
);

export type RecordOfStringByString = Asserted<
  typeof _RecordOfStringByString
>;

Constructors

new
RecordAsserter(typeName: string, unnamed 1: [KeyAsserter, ValueAsserter])

Type Parameters

KeyAsserter extends Asserter<string>
ValueAsserter extends Asserter<unknown>

Properties

readonly
keyAsserter: KeyAsserter
readonly
typeName: string
readonly
valueAsserter: ValueAsserter

Methods

assert(value: unknown, valueName?: string): Record<Asserted<KeyAsserter>, Asserted<ValueAsserter>>