Skip to content

Webpack 5 watch not failing on error #1204

Closed
@webpack-bot

Description

@webpack-bot

Bug report

What is the current behavior?

When I start webpack in watch mode it does not fail on a TypeScript error.

If the current behavior is a bug, please provide the steps to reproduce.

  1. Clone this GitHub repository: https://github.com/oliverschwendener/webpack-typescript
  2. Install dependencies: $ yarn install
  3. Start bundler in watch mode: $ yarn bundle --watch
  4. Look at bundler output. Everything should be OK.
[webpack-cli] Compilation starting...
[webpack-cli] Compilation finished
asset index.js 41 bytes [compared for emit] [minimized] (name: main)
./src/index.ts 49 bytes [built] [code generated]
webpack 5.3.2 compiled successfully in 1551 ms
[webpack-cli] watching files for updates...
  1. Add a code snippet to src/index.ts that should lead to a TypeScript error:
const x: string = 1243; // <= Type 'number' is not assignable to type 'string'.ts(2322)
console.log(x);
  1. Look at bundler output:
[webpack-cli] Compilation starting...
[webpack-cli] Compilation finished
asset index.js 41 bytes [emitted] [minimized] (name: main)
./src/index.ts 49 bytes [built] [code generated]
webpack 5.3.2 compiled successfully in 326 ms
[webpack-cli] watching files for updates...

What is the expected behavior?

I expect webpack to fail when trying to bundle my files when typescript/ts-loader detects an error. This worked fine so far when I was using webpack 4.44.2 but since I upgraded to webpack 5.3.2 this problem occurs. Interestingly this only happens when changing files after I started the watch process. When I add the failing code snippet before starting the watch process it fails as expected with the according error message:

[webpack-cli] Compilation finished
assets by status 41 bytes [cached] 1 asset
./src/index.ts 49 bytes [built] [code generated] [1 error]

ERROR in C:\Users\Oliver\projects\webpack-typescript\src\index.ts
./src/index.ts
[tsl] ERROR in C:\Users\Oliver\projects\webpack-typescript\src\index.ts(1,7)
      TS2322: Type 'number' is not assignable to type 'string'.

webpack 5.3.2 compiled with 1 error in 1554 ms
[webpack-cli] watching files for updates...

Other relevant information:
webpack version: 5.3.2
Node.js version: 14.14.0
Operating System: Windows 10 1909 (also reproducible on macOS 10.15 Catalina)
Additional tools: webpack-cli 4.1.0, ts-loader 8.0.7, typescript: 4.0.5


This issue was moved from webpack/webpack#11889 by @evilebottnawi. Original issue was by @oliverschwendener.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions