neverthrow

Represent fallible operations as Result or ResultAsync values in TypeScript and JavaScript.

6|4|Updated Nov 1, 2025
One-click install
npx skills add https://github.com/Montte-erp/montte-nx --skill neverthrow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: neverthrow
Source: https://github.com/Montte-erp/montte-nx/tree/main/.agents/skills/neverthrow
Command: npx skills add https://github.com/Montte-erp/montte-nx --skill neverthrow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Replace ad-hoc exceptions and try/catch with explicit, type-safe error values so developers cannot accidentally ignore failures and must handle errors at call sites.

Core Features & Use Cases

  • Represent fallible operations as Result (sync) or ResultAsync (async) values to encode success or failure in the type system.
  • Compose and chain operations with map, mapErr, andThen, and use safeTry generator-based do-notation to eliminate boilerplate early returns.
  • Wrap synchronous throwers and Promise-returning SDKs with Result.fromThrowable and ResultAsync.fromThrowable or fromPromise, combine parallel operations with short-circuit or collect-all semantics, and enforce consumption with an eslint plugin.
  • Real-world use case: wrap database repository work in ResultAsync<AppError> and let web routers consume results and convert errors to WebAppError without try/catch.

Quick Start

Wrap a Promise-returning SDK call with ResultAsync.fromThrowable and handle the returned ResultAsync with match to convert errors into your application error type.

Frequently Asked Questions about neverthrow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle errors in TypeScript without try/catch blocks?

Type-safe error handling without try/catch blocks is achieved by representing fallible operations as Result or ResultAsync values, enforcing explicit error handling at call sites. You compose operations using methods like map, mapErr, and andThen to handle success or failure states.

What is the best way to wrap Promise-returning SDK calls for error handling in JavaScript?

The best way to wrap Promise-returning SDK calls is using ResultAsync.fromThrowable or fromPromise. This converts exceptions or rejected promises into ResultAsync values, allowing you to handle errors safely without try/catch and convert them into application error types.

How does functional programming error handling work with async database operations?

Functional error handling for async database operations works by wrapping repository work in ResultAsync<AppError> values. Web routers consume these results and convert errors to WebAppError directly, eliminating ad-hoc exceptions and ensuring failures cannot be accidentally ignored.

Can I enforce that developers consume Result values and do not ignore errors?

Yes, you can enforce Result consumption using an ESLint plugin integration. This ensures developers handle type-safe error values at call sites and cannot accidentally ignore failures, satisfying requirements for strict error handling in TypeScript and JavaScript code.

Does TypeScript functional error handling support parallel async operations with error collection?

Yes, TypeScript functional error handling supports parallel async operations with short-circuit or error collection semantics. You combine parallel ResultAsync operations to either stop on the first error or aggregate all errors, ensuring type-safe failure management.

How do I eliminate boilerplate early returns when chaining type-safe error values?

You eliminate boilerplate early returns when chaining type-safe error values by using the safeTry generator-based do-notation. This allows you to write sequential Result or ResultAsync logic without manual early returns for failure cases.