8

GitHub - garronej/tsafe: The missing TypeScript builtins

 2 years ago
source link: https://github.com/garronej/tsafe
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

A collection of utilities to step up your TypeScript game

Documentation

Three GIFs to convince you that you need tsafe in your life

Assert thing you know are true, get runtime error if you where wrong:

Test the type definitions of your APIs:

Make TypeScript believe whatever you say:

Motivation

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 type such as ReturnType.

Documentation website

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK