Skip to content

Installation & Configuration

This guide covers how to install and configure the reTuple utility and its associated validation tooling.

You’ll need to install the utility package and the TypeScript plugin.

  1. Install the utility (production dependency):

    Installing dependencies…
    npm i @maxmorozoff/try-catch-tuple
  2. Install the TS plugin and ts-patch (dev dependencies):

    Installing dependencies…
    npm i -D @maxmorozoff/try-catch-tuple-ts-plugin ts-patch typescript

    Note ts-patch is required if you want to use the build transformer for compile-time checks. If you only need IDE feedback (LSP), you can omit it.

The tooling is configured within your tsconfig.json under compilerOptions.plugins.

This setup provides both real-time IDE feedback and build-time validation. It requires ts-patch.

tsconfig.json
{
"compilerOptions": {
// ... your other options
"plugins": [
{
"name": "@maxmorozoff/try-catch-tuple-ts-plugin", // For LSP
"transform": "@maxmorozoff/try-catch-tuple-ts-plugin/transformer", // For Build
// --- SHARED Configuration (applies to both) ---
"errorLevel": "error", // Default: "error"
"allowIgnoredError": true, // Default: true
"checkWrappedCalls": true // Default: true
}
]
}
}

If you only want IDE feedback and don’t need the build-time transformer, use this configuration.

tsconfig.json
{
"compilerOptions": {
// ... your other options
"plugins": [
{
"name": "@maxmorozoff/try-catch-tuple-ts-plugin",
// --- Optional Configuration for LSP ---
"errorLevel": "error",
"allowIgnoredError": true,
"checkWrappedCalls": true
}
]
}
}

To get real-time feedback in your editor (like VS Code):

  1. Select Workspace TypeScript Version: Ensure your editor is using your project’s installed version of TypeScript, not its own built-in version.
    • In VS Code, open a .ts file and click the version number in the status bar, then select “Use Workspace Version”.
  2. Restart TS Server: After configuring the plugin, you must restart the TypeScript Server for the changes to take effect.
    • In VS Code, open the Command Palette (Ctrl+Shift+P) and run TypeScript: Restart TS server.

You should now see errors underlined in your editor with quick fixes available.

To enable build-time checks, you need to use ts-patch.

The live compiler patches tsc on-the-fly each time it is run.

  • Command Line: Use tspc instead of tsc to compile your project.
  • Tooling: For tools like ts-node, webpack, or ts-jest, configure them to use ts-patch/compiler as the TypeScript compiler.

This method modifies the TypeScript installation in your node_modules directory. It has a lower overhead than the live compiler but requires a prepare script to remain active after npm install.

  1. Install the patch:

    Patching the TypeScript compiler…
    npx ts-patch install
  2. Add prepare script to package.json:

    package.json
    {
    "scripts": {
    "prepare": "ts-patch install -s"
    }
    }

This ensures the patch is automatically reapplied whenever dependencies are installed. For more details, see the ts-patch documentation.