It's very important to be aware that this plugin uses TypeScript's, not
webpack's modules resolution. It means that you have to setup tsconfig.json correctly.
It's because of the performance - with TypeScript's module resolution we don't have to wait for webpack to compile files.
To debug TypeScript's modules resolution, you can use tsc --traceResolution command.
Options
This plugin uses cosmiconfig. This means that besides the plugin constructor,
you can place your configuration in the:
"fork-ts-checker" field in the package.json
.fork-ts-checkerrc file in JSON or YAML format
fork-ts-checker.config.js file exporting a JS object
Options passed to the plugin constructor will overwrite options from the cosmiconfig (using deepmerge).
Name
Type
Default value
Description
async
boolean
compiler.options.mode === 'development'
If true, reports issues after webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the watch mode.
This configuration will overwrite configuration from the tsconfig.json file. Supported fields are: extends, compilerOptions, include, exclude, files, and references.
context
string
Issues options
Options for the issues filtering (issue option object).
I could write some plain text explanation of these options but I think code will explain it better:
Starts issues checking for a compilation. It's an async waterfall hook, so you can modify the list of changed and removed files or delay the start of the service.
waiting
SyncHook
compilation
Waiting for the issues checking.
canceled
SyncHook
compilation
Issues checking for the compilation has been canceled.
error
SyncHook
compilation
An error occurred during issues checking.
issues
To access plugin hooks and tap into the event, we need to use the getCompilerHooks static method.
When we call this method with a webpack compiler instance, it returns the object with
tapable hooks where you can pass in your callbacks.
When using TypeScript 4.3.0 or newer you can profile long type checks by
setting "generateTrace" compiler option. This is an instruction from microsoft/TypeScript#40063:
Set "generateTrace": "{folderName}" in your tsconfig.json (under compilerOptions)
Look in the resulting folder. If you used build mode, there will be a legend.json telling you what went where.
Otherwise, there will be trace.json file and types.json files.
Expand Process 1 with the little triangle in the left sidebar
Click on different blocks to see their payloads in the bottom pane
Open types.json in an editor
When you see a type ID in the tracing output, go-to-line {id} to find data about that type
Enabling incremental mode
You must both set "incremental": true in your tsconfig.json (under compilerOptions) and also specify mode: 'write-references' in ForkTsCheckerWebpackPlugin settings.
// don't use this pattern, if you have a monorepo with linked packages
ignored: /node_modules/,
},
};
codeframe
Available formatters are basic, codeframe and a custom function. To configurecodeframe formatter, pass: { type: 'codeframe', options: { <coderame options> } }. To use absolute file path, pass: { type: 'codeframe', pathType: 'absolute' }.
logger
{ log: function, error: function } or webpack-infrastructure
console
Console-like object to print issues in async mode.
devServer
boolean
true
If set to false, errors will not be reported to Webpack Dev Server.
dirname(configuration.configFile)
The base path for finding files specified in the tsconfig.json. Same as the context option from the ts-loader. Useful if you want to keep your tsconfig.json in an external package. Keep in mind that not having a tsconfig.json in your project root can cause different behaviour between fork-ts-checker-webpack-plugin and tsc. When using editors like VS Code it is advised to add a tsconfig.json file to the root of the project and extend the config file referenced in option configFile.
build
boolean
false
The equivalent of the --build flag for the tsc command.
mode
'readonly' or 'write-dts' or 'write-tsbuildinfo' or 'write-references'
build === true ? 'write-tsbuildinfo' ? 'readonly'
Use readonly if you don't want to write anything on the disk, write-dts to write only .d.ts files, write-tsbuildinfo to write only .tsbuildinfo files, write-references to write both .js and .d.ts files of project references (last 2 modes requires build: true).