Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 3.3 breaks auto import types in vueTemplate #375

Closed
0x00A1FA opened this issue May 12, 2023 · 13 comments
Closed

Vue 3.3 breaks auto import types in vueTemplate #375

0x00A1FA opened this issue May 12, 2023 · 13 comments

Comments

@0x00A1FA
Copy link

Hello,

I recently upgraded my project to Vue 3.3. I saw on the blog post (https://blog.vuejs.org/posts/vue-3-3) that there have been some changes to the JSX namespace (https://blog.vuejs.org/posts/vue-3-3#jsx-import-source-support).

I'm not getting types for global imports inside <template>s. I have vueTemplate: true, inside the Vite config, but I'm getting errors when using variables from auto-imports.d.ts. They work fine inside <script setup>s.

My stack is Vue 3.3.1 + Vite (latest).

Here's an example:

image

Looking forward to a timely solution.

Thanks!

@joker77877
Copy link

me too!!

@antfu
Copy link
Member

antfu commented May 17, 2023

I would love to see a minimal reproduction if someone could make one. Not sure if it's some regression related to Volar, as we are extending the ComponentCustomProperties interface.

/cc @johnsoncodehk if you have any clue

@antfu antfu changed the title Vue 3.3 breaks the vueTemplate option Vue 3.3 breaks auto import types in vueTemplate May 17, 2023
@dflock

This comment was marked as off-topic.

@dflock

This comment was marked as off-topic.

@dflock

This comment was marked as off-topic.

@dflock

This comment was marked as off-topic.

@antfu
Copy link
Member

antfu commented May 18, 2023

@dflock your issue is unrelated to the original post, please create another issue instead. Thanks. I am hiding your comments here.

@k983551019
Copy link

I would love to see a minimal reproduction if someone could make one. Not sure if it's some regression related to Volar, as we are extending the ComponentCustomProperties interface.

/cc @johnsoncodehk if you have any clue

vuejs/language-tools#3190 (comment)

@tobychidi
Copy link

This issue would soon become another "me too" movement. with the comments everywhere 🥲

Nuxt says report to Volar. Volar says report to unplugin-auto-imports and you say report to Volar.

Here is the original issue on nuxt nuxt/nuxt#20827

@xiaoxiangmoe
Copy link

Hi all, can you provide us a minimal reproduction to find some clue and then fix it?

@tobychidi
Copy link

Reproduction

image

This error doesn't seem to be reproducible on Stackblitz so I have included a github repo

Describe the bug

When functions are auto-imported from utils/ composables and used in Vue SFC Template, VsCode throws and error. Yes, I use the latest volar. This error appeared after pnpm up That bumped my Vue version to 3.3.1.

I have not tried reverting Vue versions though.

Additional context

Example:

Property 'useShowSnack' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: { key?: string | number | symbol | undefined; ref?: VNodeRef | undefined; ref_for?: boolean | undefined; ... 8 more ...; style?: unknown; }; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (arg...'.ts(2339)

@xiaoxiangmoe
Copy link

xiaoxiangmoe commented May 20, 2023

@tobychidi Hi, I try your repo in both Vue Language Features (Volar) v1.2.0 and v1.7.6. All works well for me.
image


Also I tried to run

pnpm add --save-dev vue-tsc typescript @types/node && pnpm build && ./node_modules/.bin/vue-tsc --noEmit

in your repo.

And all works well.


Is there anything I miss? Is there any body can reproduce it will vue-tsc cli?

@antfu antfu closed this as completed in b565d63 May 21, 2023
@joker77877
Copy link

image
auto-import.d.ts still reports an error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants