How to resolve typescript error for laravel mix's alias

Viewed 1175

I using react, I want to use absolute path when import component.

so I customized webpack.mix.js like below code.

That's worked well in browser.

But VScode show error.

 Could not find a declaration file for module

enter image description here

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix
    .ts('resources/js/app.tsx', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')

mix
    .webpackConfig({
        resolve: {
            extensions: [".js", ".jsx", ".tsx"],
            alias: {
                '@parts': path.resolve(__dirname, 'resources/js/components/parts'),
                '@pages': path.resolve(__dirname, 'resources/js/components/pages')
            }
        }
    });

if (mix.inProduction()) {
    mix.version()
}
0 Answers
Related