Skip to content

Webpack Dev Server not reporting errors on subsequent recompile #476

@JoshRobertson

Description

@JoshRobertson

This issue has come up during our upgrade to v5. It wasn't an issue in v4. We use babel's preset for typescript via the babel-loader for webpack.

Consider a basic type error
const x: number = "word"; //Type '"word"' is not assignable to type 'number'.ts(2322)

On initial compile with the webpack dev server, this correctly throws an error.

TS2322: Type '"word"' is not assignable to type 'number'.
  > 40 |     const x: number = "word";
       |           ^
ℹ 「wdm」: Failed to compile.

However, on a subsequent file save (with the same error still present), the dev server reports a successful compile despite the error still existing.

ℹ 「wdm」: Compiled successfully.

webpack.config.js

new ForkTsCheckerWebpackPlugin({
  eslint: undefined,
  async: false,
  issue: { scope: "webpack" },
  formatter: "codeframe",
  logger: { infrastructure: "silent", issues: "console" },
  typescript: {
    enabled: true,
    configFile: path.resolve(__dirname, "..", "..", "tsconfig.local.json"),
    diagnosticOptions: { syntactic: true, semantic: true, declaration: false, global: false },
    mode: "write-references",
    build: false,
    profile: false,
    memoryLimit: 2048,
  },
});

tsconfig.local.json

  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "importsNotUsedAsValues": "preserve",
    "lib": ["ES2020", "dom"],
    "module": "ES2020",
    "moduleResolution": "node",
    "sourceMap": true,
    "skipLibCheck": true,
    "target": "ES2019",
    "jsx": "react",
    "noUnusedLocals": true,
    "baseUrl": ".",
  },
  "include": ["app/javascript/**/*"],
  "exclude": ["node_modules"],
  "compileOnSave": true

Environment

  • @babel/preset-typescript: 7.10.4
  • babel-loader: 8.1.0
  • fork-ts-checker-webpack-plugin: 5.0.7
  • typescript: 3.9.6
  • eslint: 7.4.0
  • webpack: 4.43.0
  • webpack-dev-server: 3.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions