Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsafe

Package Overview
Dependencies
Maintainers
0
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsafe

A collection of utilities to step up your TypeScript game

  • 1.8.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
95K
increased by18.22%
Maintainers
0
Weekly downloads
 
Created
Source

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


(you can cherrypick what you import)

Documentation

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



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.

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

FAQs

Package last updated on 10 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc