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