Skip to main content


🔩 The missing TypeScript utils
Go to Latest
import * as tsafe from "";


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,

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

Return type of objectFromEntries

Shorthand for Parameters[0]

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[]