Skip to main content

Leverage the more advanced features of TypeScript
A collection of helper that makes your TS code cleaner and safer.

Home - Documentation

This module is both an NPM module and a Deno module

Import in deno:

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

Install elsewhere:

$ npm install --save tsafe
import { assert } from "tsafe/assert";
import { typeGuard } from "tsafe/typeGuard";

type Circle = { radius: number };
type Square = { sideLength: number };
type Shape = Circle | Square;

const shape: Shape = { "radius": 100 };

//You: Trust me TypeScript, I know that shape is a Circle.

//TypeScript: Ok if you say must have a radius then.