tsafe

1.8.5last stable release 5 months ago
Complexity Score
Low
Open Issues
7
Dependent Projects
66
Weekly Downloadsglobal
130,928

License

  • MIT
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Nopatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Downloads

Readme

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


You can cherry-pick what you import

Documentation



Make sure two types are identical



Playground


A assertion function that typescript understands



Make sure your zod schema exactly matches a given type:

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:

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 other utilities that cannot be just type helpers.

Documentation website

Installation

tsafe is both an NPM and a Deno module. (Achieved with denoify)

Import in deno:

import { assert, type Equals, ... } from "https://deno.land/x/tsafe/mod.ts";

Install elsewhere:

$ npm install --save tsafe

Dependencies

Loading dependencies...

CVE IssuesActive
0
Scorecards Score
3.40
Test Coverage
No Data
Follows Semver
Yes
Github Stars
426
Dependenciestotal
15
DependenciesOutdated
3
DependenciesDeprecated
0
Threat Modelling
No
Repo Audits
No

Learn how to distribute tsafe in your own private NPM registry

npm config set registry  https://npm.cloudsmith.com/owner/repo
Processing...
Done
npm install tsafe
Processing...
Done

84 Releases

NPM on Cloudsmith

Getting started with NPM on Cloudsmith is fast and easy.