ts-loader: Typescript syntax errors in happyPackMode with forked checker

I have cloned the examples directory from this repo and inside the happyPack example added the following line:

const array = [{} {}]; (missing comma)

to the bottom of the fileWithoutError.ts file and corrected the error in fileWithError.ts file

and then ran webpack.

No errors were reported. When I try to use incorrect type errors indeed are reported, but I am not sure this is enough…

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 23 (20 by maintainers)

Most upvoted comments

I think the issue is here: https://github.com/TypeStrong/ts-loader/blob/master/src/index.ts#L214

    // _module.errors is not available inside happypack - see https://github.com/TypeStrong/ts-loader/issues/336
    if (!instance.loaderOptions.happyPackMode) {
        registerWebpackErrors(
            loader._module.errors,
            formatErrors(diagnostics, instance.loaderOptions, instance.compiler, { module: loader._module })
        );
    }

In happyPackMode we cannot register transpile errors with webpack and so this info is lost. BTW the same issue would presumably apply if using thread-loader instead of happypack. Same principle; ts-loader cannot register errors with webpack.

There’s nothing that we can do from a ts-loader perspective here.

I think it should not be hard to add flag to fork-ts-checker plugin to check syntax errors.

If you could look at this that would be awesome!