Installation

Learn how to install go-errors in your TypeScript or JavaScript project.

To start using go-errors, you need to install it in your project. The package is available on npm and can be installed using bun, npm, or yarn.

bun add go-errors

Bun is known for its speed and efficiency.

Using npm

npm install go-errors

Using yarn

yarn add go-errors

TypeScript Configuration (Optional)

go-errors is written in TypeScript and includes type definitions out of the box. This means you get immediate type safety and autocompletion in your TypeScript projects without any extra configuration.

However, for the best experience, ensure your tsconfig.json file includes the following compiler options:

{
  "compilerOptions": {
    "strict": true,       // Enable all strict type-checking options.
    "esModuleInterop": true // Emit __importStar and allow importing CJS modules as default imports.
  }
}

These options enforce stricter type checking and improve compatibility with ES modules, which are recommended for modern TypeScript development.

Verifying the Installation

After installation, you can quickly verify that go-errors is correctly set up by running a simple test in your project. Create a file, for example, test-go-errors.ts or test-go-errors.js, and add the following code:

import { goSync } from 'go-errors';

// Test a simple synchronous operation
let [value, err] = goSync(() => {
  return "go-errors is installed correctly!";
});

if (err) {
  console.error("Installation verification failed:", err.message);
} else {
  console.log(value); // Should print "go-errors is installed correctly!"
}

Run this file using bun run test-go-errors.ts, npm run test-go-errors.js, or yarn run test-go-errors.js, depending on your package manager and file type. If you see the message "go-errors is installed correctly!" in your console, you're all set!

Next Steps

With go-errors successfully installed, you're ready to start simplifying your error handling! Explore these next steps:

  • Quick Start Guide: Dive into practical examples and learn the basic usage patterns.
  • Core Concepts: Deepen your understanding of the library's fundamentals.
  • API Reference: Get detailed information about all functions and types.