Cannot find module '@babel/types' or its corresponding type declarations
Version
3.2.31
Reproduction link
Steps to reproduce
This project is created by create-vite:
pnpm create vite project -- --template vue-ts
Update dependencies to the latest version then change src/main.ts
to src/index.ts
:
{
"devDependencies": {
"@vitejs/plugin-vue": "^2.2.4",
"typescript": "^4.6.3",
"vite": "^2.8.6",
"vue-tsc": "^0.33.7"
}
}
import App from './App.vue'
export default App
Change vite.config.ts
to build lib:
import { resolve } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'Test',
formats: ['es'],
fileName: 'test'
},
rollupOptions: {
external: ['vue']
}
},
plugins: [
vue()
]
})
Install project and run:
pnpm run build
What is expected?
Build successful.
What is actually happening?
Will take some errors and build fail.
If this is just a problem of vue-tsc
(volar
), please help migrate this issue, thanks.
This belongs to the vite vue template: https://github.com/vitejs/vite/issues?q=is%3Aissue+sort%3Aupdated-desc+cannot+find+module+repo%3Ababel%2Ftypes+is%3Aopen
@sqal
add
"skipLibCheck": true
to your tsconfig.json
Does this fix anything or does it just hide the underlying issue?
@sqal
add
"skipLibCheck": true
to your tsconfig.jsonDoes this fix anything or does it just hide the underlying issue?
It does.
@sqal
add
"skipLibCheck": true
to your tsconfig.jsonDoes this fix anything or does it just hide the underlying issue?
It does.
I'm not sure that this "fixes" the issue as @f1am3d says. It seems like it just hides it to me. Sure, vue-tsc no longer complains about third party code in node_modules, but if you've got *.d.ts files to declare types for other libraries in your project, it skips them on the type check as well. That's not an option in my case. Is there a workaround to avoid node_modules but allow your own .d.ts files?