DEV Community

Sardorbek Imomaliev
Sardorbek Imomaliev

Posted on

TIL: TypeScript | Fix "TS2307: Cannot find module 'src' or its corresponding type declarations."

Story

After I updated my package.json and installed all dependencies, my npm run build started failing with

$ npm run build

> vite-vue-typescript-starter@0.0.0 build
> vue-tsc --noEmit && vite build

node_modules/@vue/test-utils/dist/domWrapper.d.ts:5:28 - error TS2307: Cannot find module 'src' or its corresponding type declarations.

5 import { VueWrapper } from 'src';
                             ~~~~~


Found 1 error.
Enter fullscreen mode Exit fullscreen mode

Question

How to fix?

error TS2307: Cannot find module 'src' or its corresponding type declarations.
Enter fullscreen mode Exit fullscreen mode

Answer

This was a tricky one because at a first glance it may seem that I have a typescript problem in project which is technically correct, but actually this is a bug in @vue/test-utils-next library which was introduced in 2.0.0-rc.14 version. Installing 2.0.0-rc.13 or setting skipLibCheck: true in tsconfig.json solves this. For my case, I've chosen the first approach.

What I Learned

  1. skipLibCheck: true > Skip type checking of declaration files.

Links

Top comments (2)

Collapse
 
louvani profile image
Louvani

Thank you a lot!!!

Collapse
 
charlesokwuagwu profile image
Charles

this helped me. thanks