Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
January 31, 2023 03:29
January 30, 2023 00:43
May 10, 2021 11:00
March 29, 2021 21:49
May 7, 2021 13:42
May 10, 2021 11:00
March 29, 2021 21:49
December 3, 2022 15:54
July 26, 2022 03:09
January 30, 2023 00:40

A collection of utilities to take your TypeScript development up a notch

(you can cherrypick what you import)


A few GIFs to convince you that you need tsafe in your life

Assert things you know are true, get runtime errors where you were wrong:

Implement compile time unit testing


Make sure all properties of an object are deconstructed


Make sure you never forget a case in a switch


Make TypeScript believe whatever you say without having to write const obj2 = obj as Bar.
The more powerfully is to be able to tell TypeScript that obj ist not of type Bar:


Powerful TypeScript features like assertion functions or user-defined type guards are only useful if paired with utility functions.

TypeScript, however, only exports type helpers (e.g. Record, ReturnType, etc.).

This module provides «the missing builtins» such as the assert function and corrects frustrating aspects of default utility types such as ReturnType.

Documentation website


tsafe is both an NPM and a Deno module. (Achieved with denoify)

Import in deno:

import { assert, typeGuard, ... } from "";

Install elsewhere:

$ npm install --save tsafe
$ yarn add tsafe