All Projects → aikoven → assert-never

aikoven / assert-never

Licence: other
Helper function for exhaustive checks of discriminated unions in TypeScript

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to assert-never

Baloo
Expressive end-to-end HTTP API testing made easy in Go
Stars: ✭ 702 (+2093.75%)
Mutual labels:  assert
Ppk assert
PPK_ASSERT is a cross platform drop-in & self-contained C++ assertion library
Stars: ✭ 164 (+412.5%)
Mutual labels:  assert
Power Assert
Power Assert in JavaScript. Provides descriptive assertion messages through standard assert interface. No API is the best API.
Stars: ✭ 2,704 (+8350%)
Mutual labels:  assert
Testify
A unit testing framework written in bash for bash scripts
Stars: ✭ 45 (+40.63%)
Mutual labels:  assert
Earl
☕ Ergonomic, modern and type-safe assertion library for TypeScript
Stars: ✭ 153 (+378.13%)
Mutual labels:  assert
Swiftpowerassert
Power Assert in Swift. Provides descriptive assertion messages.
Stars: ✭ 191 (+496.88%)
Mutual labels:  assert
Validator.js
⁉️轻量级的 JavaScript 表单验证,字符串验证。没有依赖,支持 UMD ,~3kb。
Stars: ✭ 486 (+1418.75%)
Mutual labels:  assert
ruling
Stateless rule engine
Stars: ✭ 19 (-40.62%)
Mutual labels:  assert
Resumable Assert
Assert replacement to continue execution in debugger
Stars: ✭ 157 (+390.63%)
Mutual labels:  assert
Check Types.js
MOVED TO GITLAB
Stars: ✭ 232 (+625%)
Mutual labels:  assert
Assert
A collection of convenient assertions for Swift testing
Stars: ✭ 69 (+115.63%)
Mutual labels:  assert
Gopwt
PowerAssert library for golang
Stars: ✭ 137 (+328.13%)
Mutual labels:  assert
Power assert ex
Power Assert in Elixir. Shows evaluation results each expression.
Stars: ✭ 201 (+528.13%)
Mutual labels:  assert
Regex Assert Symfony
Common Regex to use with Assert in Symfony's entity
Stars: ✭ 5 (-84.37%)
Mutual labels:  assert
chai-exclude
Exclude keys to compare from a deep equal operation with chai expect or assert.
Stars: ✭ 33 (+3.13%)
Mutual labels:  assert
Node Deep Equal
node's assert.deepEqual algorithm
Stars: ✭ 577 (+1703.13%)
Mutual labels:  assert
Debug assert
Simple, flexible and modular assertion macro.
Stars: ✭ 181 (+465.63%)
Mutual labels:  assert
unreachable
Utility function for exhaustiveness checking with typed JS (TS or Flow)
Stars: ✭ 14 (-56.25%)
Mutual labels:  discriminated-unions
ExhaustiveMatching
C# Analyzer Adding Exhaustive Checking of Switch Statements and Expressions
Stars: ✭ 60 (+87.5%)
Mutual labels:  discriminated-unions
Gotest.tools
A collection of packages to augment the go testing package and support common patterns.
Stars: ✭ 205 (+540.63%)
Mutual labels:  assert

Assert Never npm version

Helper function for exhaustive checks of discriminated unions in TypeScript.

Installation

npm install --save assert-never

Usage

import {assertNever} from "assert-never";

type A = {type: 'a'};
type B = {type: 'b'};
type Union = A | B;

function doSomething(arg: Union) {
  if (arg.type === 'a') {
    return something;
  }

  if (arg.type === 'b') {
    return somethingElse;
  }

  // TS will error if there are other types in the union
  // Will throw an Error when called at runtime. Use `assertNever(arg, true)`
  // instead to fail silently.
  return assertNever(arg);
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].