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": [
"es2019",
"dom"
],
"removeComments": true,
"noUnusedLocals": false
}
}
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
・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"
module.exports = {
...
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
]
}
]
}
}
use ignoreDiagnostics
to ignore certain TypeScript errors, but this is more applicable when you just want to run code
{
test: /\.tsx?$/,
use: "ts-loader",
options: {
ignoreDiagnostics: [2322]
}
},
https://www.npmjs.com/package/ts-loader#ignorediagnostics
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With