Skip to main content
Module

x/typeguardkit/mod.ts>TypeAsserter

A TypeScript module to help construct type assertion functions and type guards.
Latest
class TypeAsserter
implements Asserter<Type>
Re-export
import { TypeAsserter } from "https://deno.land/x/typeguardkit@0.32.1/mod.ts";

A TypeAsserter<Type> is an Asserter<Type> that uses typeGuard to assert whether value is of Type.

Example:

import { TypeAsserter } from "typeguardkit";

export const _string = new TypeAsserter(
  "string",
  (value): value is string => typeof value === "string",
);

Constructors

new
TypeAsserter(typeName: string, typeGuard: (value: unknown) => value is Type)

Properties

readonly
typeName: string

Methods

assert(value: unknown, valueName?: string): Type