vue3 error message prompts that the module "./XXX.vue" or its corresponding type declaration cannot be found
I found many methods on the Internet, such as adding: under the tsconfig file:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
]
}
},
"exclude": [
"node_modules",
"dist"
]
}
This doesn't work for me at all.
Later I saw that you can create a file with the suffix .d.ts in the src root directory and
write the following code:
declare module '*.vue' {
import type { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
}
The problem is solved and the module not found error is no longer reported.