- v1.8.4Latest
- v1.8.3
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.5
- v1.7.5-rc.0
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.6
- v1.6.5
- v1.6.4
- v1.6.4-rc.1
- v1.6.4-rc.0
- v1.6.3
- v1.6.1
- v1.6.0
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.3
- v1.4.2
- v1.4.2-rc.4
- v1.4.2-rc.3
- v1.4.2-rc.1
- v1.4.2-rc.0
- v1.4.1
- v1.4.0
- v1.4.0-rc.1
- v1.4.0-rc.0
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.3
- v1.1.3-rc.0
- v1.2.0-beta.0
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
- v0.10.1
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.1
- v0.8.0
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.1
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.15
- v0.1.14
- v0.1.13
- v0.1.12
- v0.1.11
- v0.1.10
- v0.1.9
A collection of utilities to take your TypeScript development up a notch
(you can cherrypick what you import)
tsafe
in your life
A few 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
Playground
Make sure all properties of an object are deconstructed
Playground
Make sure you never forget a case in a switch
Playground
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
:
Make sure your zod schema exactly matches a given type:
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