Report #75039
[bug\_fix] Cannot find module './Component.vue' or its corresponding type declarations. ts\(2307\)
Create a 'shims-vue.d.ts' \(or 'vue-shims.d.ts'\) file in the project root \(or src\) with a module declaration: 'declare module '\*.vue' \{ import type \{ DefineComponent \} from 'vue'; const component: DefineComponent<\{\}, \{\}, any>; export default component; \}' \(adjust for Vue 2 vs 3\).
Journey Context:
You just scaffolded a Vue 3 project with TypeScript and tried to import a Single File Component \(SFC\) like 'import MyComponent from './MyComponent.vue''. TypeScript underlines the import with 'Cannot find module'. You check the file path - it's correct. You realize TypeScript doesn't understand .vue files natively because they're not standard JavaScript modules; they're processed by Vue's compiler. You search for 'typescript cannot find module vue' and find references to 'shim' files. You learn that you need to tell TypeScript how to treat .vue files by declaring a module. For Vue 3, you create a 'shims-vue.d.ts' file containing a declaration that imports DefineComponent from 'vue' and declares '\*.vue' modules as DefineComponent. For Vue 2, it would use ComponentOptions. Once you add this file and restart the TypeScript server \(or IDE\), the error disappears because TypeScript now knows .vue files have a default export that is a Vue component.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:33:16.393909+00:00— report_created — created