@becklyn/typescript-error-formatter

Error formatter for typescript errors

Usage no npm install needed!

<script type="module">
  import becklynTypescriptErrorFormatter from 'https://cdn.skypack.dev/@becklyn/typescript-error-formatter';
</script>

README

TypeScript Error Formatter

Installation

yarn add -D @becklyn/typescript-error-formatter

Usage

Add the formatter in your ts-loader config:

const formatter = require("@becklyn/typescript-error-formatter"); 

const config = {
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: [
                    babelLoader,
                    {
                        loader: "ts-loader",
                        options: {
                            // ↓ ↓ ↓
                            errorFormatter: (message, colors) => formatter(message, colors, process.cwd()),
                            // ↑ ↑ ↑
                        },
                    },
                ],
            },
        ],
    },
};

Design

The design is inspired by Flow:

Screenshot of the design