Cannot resolve TypeScript type declaration for ECMAScript Module (.d.mts)

Environment:

  • New project → Vue.js
  • Vite 7 (released June 24, 2025)
  • TypeScript with ESM declarations (.d.mts) (previously .d.ts in Vite 6)

Issue:
In vite.config.ts:

import vue from '@vitejs/plugin-vue'

WebStorm shows this problem:

Vue: Cannot find module @vitejs/plugin-vue or its corresponding type declarations.
There are types at
./node_modules/@vitejs/plugin-vue/dist/index.d.mts
, but this result could not be resolved under your current moduleResolution setting. Consider updating to node16, nodenext, or bundler

Note:
My tsconfig.json already has moduleResolution set to bundler:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "bundler",
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "useDefineForClassFields": true,
    "types": ["node", "vite/client"],
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist"]
}

Build and run work fine without any errors—this problem only appears in the IDE.

Question:
How can I get WebStorm (or TypeScript/Vue engine) to properly resolve .d.mts files?

 

0

It works for me with vite@7.0.3:

As far as I can see, both index.d.mts and index.d.ts are available in @vitejs/plugin-vue/dist:

What is a result of running vue-tsc for your app?

0

Hi,

vue-tsc shows no errors.

There are .d.ts files in Vite as well, but it seems the IDE isn’t picking them up.

This problem happens with every .d.mts declaration, including ones from Tailwind CSS.

0
Do you have a sample project you can share that reproduces the issue?
0

Sure, I’ve uploaded it to GitHub: luyiourwong/mtxtest: sample project for intellij support #27973940568082
This project was basically created from New Project with just a few small modifications to setup TypeScript.
The tsconfig.json is configured based on the official Vue documentation:
https://vuejs.org/guide/typescript/overview.html#configuring-tsconfig-json

0

Thank you!

The corresponding moduleResolution is indeed configured in the tsconfig.json, but the vite.config.ts the error is reported for is not included in it. Adding this file to the include: list should help:

"include": ["src", "vite.config.ts"],
2

Thank you, this was helpful. I hadn’t considered it could be related to it since the warning pointed to external references. Appreciate your help!

0

请先登录再写评论。