Is there a way to prevent WebPack's build process from failing when the TypeScript compiler throws errors about unresolved variables that are already configured in Webpack's ProvidePlugin settings?
webpack.config.js
plugins: [
...
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
"_": "underscore",
"underscore": "underscore"
//'process.env.NODE_ENV': '"development"'
}),
]
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"declaration": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
Based on my experience, TypeScript doesn't recognize the variables injected into the module, causing the build to fail.
This is the build output
ERROR in ./src/file1.component.ts
(77,9): error TS2304: Cannot find name '$'.
ERROR in ./src/file2.component.ts
(78,13): error TS2304: Cannot find name '$'.
ERROR in ./src/file3.ts
(155,15): error TS2304: Cannot find name 'jQuery'.
ERROR in ./src/file4.ts
(108,9): error TS2304: Cannot find name '$'.