Skip to main content
Module

x/silicon/deps.ts>isLiteralOneOf

Deno module to generate images from source code using Aloxaf/silicon.
Latest
function isLiteralOneOf
import { isLiteralOneOf } from "https://deno.land/x/silicon@v1.0.0/deps.ts";

Return a type predicate function that returns true if the type of x is one of literal type in preds.

import is from "./is.ts";
const a: unknown = "hello";
if (is.LiteralOneOf(["hello", "world"] as const)(a)) {
 // a is narrowed to "hello" | "world"
 const _: "hello" | "world" = a;
}

Type Parameters

T extends readonly Primitive[]

Parameters

literals: T

Returns

Predicate<T[number]>