Skip to content

Vue 3 + Volar: TS2307 “Cannot find module '*.vue'” when plugin is enabled #286

@lfazliev

Description

@lfazliev

Environment

typescript                 5.8.3
typescript-plugin-css-modules 5.1.0
vue                        3.5.17
@vitejs/plugin-vue         6.0.0
VS Code                    1.102.1
Volar extension            v3.0.3 (built-in)
OS                         Windows 11

tsconfig (reduced)

{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "compilerOptions": {
    "plugins": [{ "name": "typescript-plugin-css-modules" }]
  },
  "include": ["src/**/*", "src/**/*.vue"]
}

Steps to reproduce

  1. npm create vue@latest (or any fresh Vue 3 + TS + Volar project)
  2. npm i -D typescript-plugin-css-modules
  3. Add the plugin to compilerOptions.plugins as above
  4. Open VS Code → wait until TS Server restarts

Expected
• SFC imports still resolve, e.g.

import Home from './Home.vue'

type checks without errors, while CSS-module types are available.

Actual
• Types for style modules works correctly
but
• Every import X from './*.vue' shows TS2307: Cannot find module ‘…’

If I remove the plugin line, the errors disappear immediately.

Minimal repro repo

Additional context / hypothesis
It looks as if the plugin overrides resolveModuleNames and doesn’t fall back to the default resolver for unknown extensions (.vue). Volar relies on .vue being resolvable, so type acquisition breaks.

Is there a way to let the plugin coexist with the default resolver (or to whitelist .vue)?
Happy to test nightly builds or provide more logs if needed.

Thanks! 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions