Fork TS Checker Async Overlay Webpack Plugin
raw JSON →A webpack plugin that connects fork-ts-checker-webpack-plugin (with async: true) to the error overlay of webpack-dev-server. Version 0.4.0 is the latest stable release. The plugin addresses the limitation that type checking errors from fork-ts-checker-webpack-plugin are not shown in the dev server overlay when running asynchronously (async: true). It works by re-firing the webpack-dev-server's done hook after type checking completes, but only if there are errors, to avoid unnecessary page reloads. It requires fork-ts-checker-webpack-plugin ^4.1.6 as a peer dependency and is intended for use with ts-loader's transpileOnly option. Key differentiator: allows fast incremental builds (async: true) while still showing type errors in overlay, avoiding the need to set async: false which slows down builds.
Common errors
error Type errors not showing in overlay even though fork-ts-checker-webpack-plugin reports them ↓
error Cannot find module 'fork-ts-checker-async-overlay-webpack-plugin' ↓
error TypeError: ForkTsCheckerAsyncOverlayWebpackPlugin is not a constructor ↓
Warnings
gotcha Only errors (not warnings) are shown in overlay. ↓
gotcha The plugin requires devServer.overlay to be true and devServer.inline to be true. ↓
gotcha The plugin only re-fires the done hook if there are errors; otherwise the overlay is not updated. ↓
breaking Major version 0.x: API may change without notice. Peer dependency on fork-ts-checker-webpack-plugin ^4.1.6 may not be compatible with newer versions. ↓
Install
npm install fork-ts-checker-async-overlay-webpack-plugin yarn add fork-ts-checker-async-overlay-webpack-plugin pnpm add fork-ts-checker-async-overlay-webpack-plugin Imports
- default wrong
import ForkTsCheckerAsyncOverlayWebpackPlugin from 'fork-ts-checker-async-overlay-webpack-plugin'correctconst ForkTsCheckerAsyncOverlayWebpackPlugin = require('fork-ts-checker-async-overlay-webpack-plugin') - ForkTsCheckerAsyncOverlayWebpackPlugin
const ForkTsCheckerAsyncOverlayWebpackPlugin = require('fork-ts-checker-async-overlay-webpack-plugin')
Quickstart
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ForkTsCheckerAsyncOverlayWebpackPlugin = require('fork-ts-checker-async-overlay-webpack-plugin');
module.exports = {
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'ts-loader',
options: { transpileOnly: true }
},
exclude: /node_modules/
}
]
},
plugins: [].concat(
new ForkTsCheckerAsyncOverlayWebpackPlugin({
checkerPlugin: new ForkTsCheckerWebpackPlugin()
}).plugins()
),
devServer: {
overlay: true,
inline: true
}
};