Open hungify opened 8 months ago
A bit of additional context: this happens when you try to import a .vue
file from a .ts
file (in this case main.ts
).
Inside .ts file |
Inside .vue file |
---|---|
P.S. Somewhat unrelated, but note how you can import ./App.vue
from within App.vue
, which could be considered a bug.
Same issue here, it happens when trying to import the App.vue
component within a .ts
file.
Hey guys!
To fix this error, add a shim file for Vue files.
Create a new file like shims-vue.d.ts
in the src folder (same level as main.ts
) and add the following code.
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<object, object, any>
export default component
}
Yeah, that's it. This error will be gone.
cc: @Moshyfawn @segovia-no
@hungify Problem with this solution is it seems to break Go to Definition. For example, do Go to Definition on App
in main.ts
and it takes you to the shim file.
try adding this to your tsconfig.json "plugins": [{ "name": "@vue/typescript-plugin" }]
,
and installing @vue/typescript-plugin
in your dev deps.
You should not need to add the shim.
I think vscode does this automatically but i'm not sure of the details
Confirmed that @fazulk suggestion worked.
To clarify, install @vue/typescripot-plugin
. Npm Example:
npm i -D @vue/typescript-plugin
Add the plugin to your compilerOptions
. Example tsconfig.json with only the plugin. Make sure yours is an addition
{
"compilerOptions": {
"plugins": [{ "name": "@vue/typescript-plugin" }]
}
}
Hoping I can daily drive Zed now 🤞
This should be a problem with the vue plugin, the official vscode plugin for vue is solving the problem of conflicts between the two language servers
Check for existing issues
Describe the bug / provide steps to reproduce it
Look at the screenshot, it's weird.
It's fine on VS Code.
Repo: https://github.com/hungify/zed-vue-resolve-import
Environment
Zed: v0.124.4 (Zed Preview) OS: macOS 14.3.1 Memory: 16 GiB Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.If you only need the most recent lines, you can run the
zed: open log
command palette action to see the last 1000.