Skip to main content

Requirements

ts-chas is a TypeScript-first library. You need:
  • TypeScript 4.7 or later (5.x recommended)
  • Node.js 16 or later

Install the package

npm install ts-chas

Import what you need

The package ships with a single top-level namespace and several focused sub-path exports. Import only the modules your code uses.
// The full namespace, includes everything
import { chas } from 'ts-chas';

// Result API only
import type { Result, ResultAsync, ... } from 'ts-chas/result';

// Guard API only
import { is, ... } from 'ts-chas/guard';

// Option API only
import { Option, ... } from 'ts-chas/option';

// .pipe() and .flow() utilities only
import { pipe, flow } from 'ts-chas/pipe';

// Task class only
import { Task } from 'ts-chas/task';

// Tagged Errors API only
import { defineErrs, InferErr, ... } from 'ts-chas/tagged-errs';
Using sub-path imports keeps your bundle smaller: your bundler tree-shakes everything in the sub-path rather than the full library.

ESM and CommonJS

ts-chas ships both an ESM build (dist/index.js) and a CommonJS build (dist/index.cjs). Node.js, bundlers, and runtimes that support the exports field in package.json automatically receive the correct format with no extra configuration needed.