Home

Awesome

pheno

Simple, lightweight at-runtime type checking functions, with full TypeScript support

Features

Usage Example

import * as types from "pheno";

function something(first: unknown, second: unknown) {
  // Throws an error if `first` is not a string
  types.assertType(first, types.string);

  // Throws an error if `second` is not `string | number`
  types.assertType(second, types.union(types.string, types.number));

  // Typescript now knows that `first` is a string and `second` is `string | number`
  return first + " " + String(second);
}

List of types and type builder functions

Please see the TypeScript types for each of these in either your editor's autocomplete or pheno's source code for more information.

License

MIT