How to ignore typescript errors when compile by webpack production mode



webpack 4.41.2

typescript 3.7.2


When I compile files by webpack development mode, there is no problem.
But when I compile by production mode, there is a lot of errors and I can’t compile.


find the way how to ignore typescript errors when webpack compiles by production mode


▼webpack.config.js (js part)

    mode: "development",
    entry: "./src/index.tsx",
    output: {
        path: `${__dirname}/dist`,
        filename: "index.js"
    module: {
        rules: [
                test: /\.tsx?$/,
                use: "ts-loader"
                test: /\.svg$/,
                loader: "react-svg-loader",
                options: {
                    svgo: {
                        plugins: [
                            { removeTitle: false }
                        floatPrecision: 2
                test: /\.(vert|frag|glsl)$/,
                use: {
                    loader: 'webpack-glsl-loader'
    resolve: {
        extensions: [".ts", ".tsx", ".js", ".json"]

▼ tsconfig

  "compilerOptions": {
    "sourceMap": false,
    "target": "es5",
    "module": "es2015",
    "jsx": "react",
    "moduleResolution": "node",
    "lib": [
    "removeComments": true,
    "noUnusedLocals": false

error content

ERROR in /var/www/hoge/src/index.tsx
[tsl] ERROR in /var/www/hoge/src/index.tsx(56,33)
      TS2322: Type '(page: any) => void' is not assignable to type 'void'.

ERROR in /var/www/hoge/src/about/index.tsx
[tsl] ERROR in /var/www/hoge/src/about/index.tsx(15,48)
      TS2339: Property 'appRef' does not exist on type 'About'.

ERROR in /var/www/hoge/src/gallery/index.tsx
[tsl] ERROR in /var/www/hoge/src/gallery/index.tsx(8,27)
      TS2307: Cannot find module './picturesData'.

ERROR in /var/www/hoge/src/gallery/index.tsx
[tsl] ERROR in /var/www/hoge/src/gallery/index.tsx(9,9)
      TS2529: Duplicate identifier 'Promise'. Compiler reserves name 'Promise' in top level scope of a module containing async functions.

...and other almost similar 40 errors

What I’ve tried so far

・check similer post in Internet like these
Ignore Typescript errors in Webpack-dev-server
How to ignore typescript errors with webpack?
but it doesn’t help me

・add this code to tsconfig.js

"no-consecutive-blank-lines": false,
"no-unused-variable": false,

but error “Unknown compiler option”


add // @ts-nocheck in all files, and compiled. (I think there is other better way though)

Answered By – kazon

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published