I've been working on a Vue 2 application that is mostly JavaScript, and now I am looking to incorporate some new TypeScript modules and components into it.
Everything runs smoothly when I start the webpack dev server. However, whenever I make a change and the page reloads automatically, an error pops up:
Compiled with problems:X
ERROR
D:\Code\app\js_src\core\ui\alert.ts
./js_src/core/ui/alert.ts 19:19-72
[tsl] ERROR in D:\Code\app\js_src\core\ui\alert.ts(19,20)
TS2307: Cannot find module './alert.ts?vue&type=custom&index=0&blockType=Action' or its corresponding type declarations.
... (remaining errors omitted for brevity) ...
webpack.dev.js
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
hot: true,
historyApiFallback: {
index: '/static/dist/index.html'
},
},
});
webpack.common.js
...(content of webpack.common.js shown here)...
tsconfig.json
...(content of tsconfig.json shown here)...
If I follow the configuration provided above, or switch the component script language to JavaScript, everything works fine.