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

New v3.3 syntax for defineEmits does not work #3169

Closed
rodrigocfd opened this issue May 11, 2023 · 8 comments · Fixed by #3283
Closed

New v3.3 syntax for defineEmits does not work #3169

rodrigocfd opened this issue May 11, 2023 · 8 comments · Fixed by #3283
Labels
enhancement New feature or request

Comments

@rodrigocfd
Copy link

Vue 3.3 introduced a new syntax for defineEmits:

const emit = defineEmits<{
  'update:modelValue': [id: number];
  foo: [value: string];
}>();

Which is not supported by Volar yet.

@Noxdor
Copy link

Noxdor commented May 16, 2023

Could you describe more in which way you are realising this issue? For me, type definitions when defining emits with the new syntax are not working properly. I falsely published that here but I think it has to do with the current version of volar LSP not being up to date with Vue 3.3.

@rodrigocfd
Copy link
Author

Could you describe more in which way you are realising this issue?

I just tried the new syntax, and it didn't work... just that.

@jdk2pq
Copy link

jdk2pq commented May 16, 2023

I'm seeing the same issue when I try to use the new defineEmits syntax and run vue-tsc --noEmit as part of my pre-commit hook. I get errors like these:

error TS2344: Type 'Emits' does not satisfy the constraint '((...args: any[]) => any) | Record<string, any[]>'.
Type 'Emits' is not assignable to type 'Record<string, any[]>'.
    Index signature for type 'string' is missing in type 'Emits'.

when doing something like

interface Emits {
    someEmit: [value: string];
}

const emits = defineEmits<Emits>();

and this error:

Argument of type 'string' is not assignable to parameter of type 'Emits'.

when trying:

emits('someEmit', value);

@rodrigocfd
Copy link
Author

It's working now, apparently after the last vue/core 3.3.2 release.

@Noxdor
Copy link

Noxdor commented May 17, 2023

I am on 3.3.2 and the issue is not fixed for me, I will open a new issue then.

@jdk2pq
Copy link

jdk2pq commented May 22, 2023

@Noxdor can confirm. still a problem for me on Vue 3.3.4 and vue-tsc 1.7.8

@mauricewegner
Copy link

Autocompletion with the new syntax is currently missing as well.

image

@so1ve
Copy link
Member

so1ve commented Jun 14, 2023

#3283

@johnsoncodehk johnsoncodehk added the enhancement New feature or request label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants