Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/tsafe/mod.ts

🔩 The missing TypeScript utils
Go to Latest
import * as tsafe from "https://deno.land/x/tsafe@v1.2.1/mod.ts";

Functions

Return a function to use as Array.prototype.filter argument to exclude one or many primitive value element from the array. Ex: ([ "a", "b", "c" ] as const).filter(exclude("a")) return ("b" | "c")[] Ex: ([ "a", "b", "c", "d"] as const).filter(exclude(["a", "b"]) gives ("c" | "d")[]

Flip the value of a boolean without having to reference it twice after running flip(x.y, "z") x.y.z !== x.y.z, https://docs.tsafe.dev/flip

Removes the enumerable properties whose values are undefined.

Always return null but pretends it returns an object of type T

Type Aliases

Ensure that a that a specific type that we are declaring extends a more generic type

Return type of objectEntries https://docs.tsafe.dev/objectentries

Return type of objectFromEntries https://docs.tsafe.dev/objectFromEntries

Shorthand for Parameters[0] https://docs.tsafe.dev/param0

PickOptionals<{ p1: string; p2?: string; p3?: number; }> is the type { p2: string; p3: number; }

Use case: declare const pr: Promise<string[]>; const x: UnpackPromise; <== x is string[]