Skip to content
Advertisement

Webpack throws error when trying to use ts-loader

I’ve looked at all the Google results regarding this issue, but can’t find any reason why it won’t work in my case. I get this error:

JavaScript

This is my webpack.config.js:

JavaScript

My tsconfig.json:

JavaScript

For some reason, the TypeScript syntax is considered invalid and therefore the bundle won’t be created. I’ve tried running Babel after TS and vice versa, but that doesn’t solve it either. Any idea what the issue might be and how to fix it?

Advertisement

Answer

You can install the TypeScript compiler and the TypeScript loader from npm by running:

JavaScript

tsconfig.json:

JavaScript

webpack.config.js . A basic webpack with TypeScript config should look along these lines:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement