Closed amir20 closed 1 year ago
Just a note that this is only happening in VSCode. Build is fine.
I have been debugging this and strangely using a vitesse
doesn't produce this problem. So I attempted to make my configurations identical and still no luck. Also this IDE error is only happening on vue template.
tsconfig.js
{
"compilerOptions": {
"baseUrl": ".",
"module": "ESNext",
"target": "ESNext",
"lib": ["DOM", "ESNext"],
"strict": true,
"esModuleInterop": true,
"jsx": "preserve",
"skipLibCheck": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"types": ["vitest", "vite/client", "vue/ref-macros", "vite-plugin-pages/client"],
"paths": {
"@/*": ["assets/*"]
}
},
"include": ["assets/**/*.ts", "assets/**/*.vue", "assets/**/*.json", "assets/**/*.d.ts", "assets/auto-imports.d.ts"],
"exclude": ["dist", "node_modules", "e2e"]
}
vscode settings.json
seems similar.
vite.config.ts
AutoImport({
imports: ["vue", "vue-router", "vue-i18n", "vue/macros", "pinia", "@vueuse/head", "@vueuse/core"],
dts: "assets/auto-imports.d.ts",
dirs: ["assets/composables", "assets/stores", "assets/utils"],
vueTemplate: true,
}),
Still IDE cannot find those imports.
Has anybody else seen this? I guess my next attempt is slowly add files to the vitess
sample app until it's the same.
I have been unable to figure out the problem.
I created https://github.com/amir20/autoimport-bug to show the bug.
git clone https://github.com/amir20/autoimport-bug
cd autoimport-bug
ni
code .
I hope someone else can reproduce this.
I can confirm vue-tsc --noEmit
throws the error.
I might be entering some dimension I have never seen before đŸ˜…
I noticed npm i
works. But removing node_modules and package-lock.json
with pnpm i
doesn't work.
I am hoping @antfu has an idea at this point. There might be some transitive dep missing that I can't reproduce.
I was able to find the root cause. pnpm
doesn't hoist all packages at top. The fix was to add shamefully-hoist=true
and I noticed vitesse
also has this setting.
I found nothing documented that would explain this. I imagine this would be a problem for majority of users of this page because even vue-tsc
fails.
Possible related issues https://github.com/antfu/unplugin-vue-components/issues/177
An update to the documentation would be nice.
You can try pnpm i -D @vue/runtime-core
then restart vscode (maybe a workaround)
Yup, I found that after I did the original solution. Still I am not sure if it is expected to run to this issue. I don't see it documented.
Hmm I was wrong. @vue/runtime-core
doesn't seem to work for me. I remember one package might have fixed it. I don't remember which one now.
Here a reproduction: https://github.com/qmhc/auto-import-test, you can follow the steps in README.
Describe the bug
I have the following code:
When using this in vue template, VScode shows an error like so:
I have also tested with functions and same error. The error is not there in
<script>
blocks, just vue template.My config does have vue enabled.
I am out of ideas.
Reproduction
I haven't created one yet. I can do so if needed.
System Info
Used Package Manager
pnpm
Validations