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

x/typeguardkit/mod.ts>EnumAsserter

A TypeScript module to help construct type assertion functions and type guards.
Latest
class EnumAsserter
implements Asserter<Enum[keyof Enum]>
import { EnumAsserter } from "https://deno.land/x/typeguardkit@0.33.0/mod.ts";

An EnumAsserter is an Asserter for the union of the member types of the provided enumObject.

The provided enumObject is made accessible as a property of the created EnumAsserter.

Example:

import { EnumAsserter } from "typeguardkit";

export enum Direction {
  Up,
  Right,
  Down,
  Left,
}

export const _Direction = new EnumAsserter("Direction", Direction);

Constructors

new
EnumAsserter(typeName: string, enumObject: Enum)

Type Parameters

Enum extends Record<string, number | string>

Properties

readonly
typeName: string

Methods

assert(value: unknown, valueName?: string): Enum[keyof Enum]