Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/tsafe/index.ts

🔩 The missing TypeScript utils
Go to Latest
import * as tsafe from "https://deno.land/x/tsafe@v1.7.2/index.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; }

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

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