A collection of utilities for stepping up your TypeScript game
tsafe
in your life
Three GIFs to convince you that you need
Assert things you know are true, get runtime errors where you were wrong:
Implement compile time unit testing (example):
Make TypeScript believe whatever you say:
Motivations
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
.
Installation
tsafe
is both an NPM and a Deno module.
(Achieved with denoify)
Import in deno:
import { assert, typeGuard, ... } from "https://deno.land/x/tsafe/mod.ts";
Install elsewhere:
$ npm install --save tsafe
#OR
$ yarn add tsafe