@k88/typescript-compile-error-formatter

Formats Typescript error messages from Fork TS Checker Webpack Plugin

Usage no npm install needed!

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

README

@k88/typescript-compile-error-formatter

A error formatter for typescript compile errors, taken from react-dev-utils, but is published as a standalone module and has Typescript definition.

Installation

This formatter best works with the output of fork-ts-checker-webpack-plugin and is used as a peer dependency. Install both using:

npm install @k88/typescript-compile-error-formatter fork-ts-checker-webpack-plugin --save-dev

Usage

Use it for a formatted error message form fork-ts-checker-webpack-plugin:

import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import typescriptFormatter from '@k88/typescript-compile-error-formatter';

forkTsCheckerWebpackPlugin
    .getCompilerHooks(compiler)
    .receive.tap('afterTypeScriptCheck', (diagnostics, lints) => {
        [...diagnostics, ...lints].forEach(msg, => typescriptFormatter(msg, true));
      });