Skip to content

Add support for stricter type-literal option in vue/define-emits-declaration #2315

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

Merged

Conversation

Meesayen
Copy link
Contributor

Fixes: #2242

This PR adds support for a stricter check to always use the "type literal" type based defineEmits signature introduced in Vue 3.3.

i.e.

defineEmits<{
  // this line is good
  change: [value: string]

  // this line is bad
  (e: 'change', value: string): void
}>()

Not included in this PR is a strict check on the use of named tuples. Maybe it can be added as an extra sub-option to the type-literal option in the future, if possible.

Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you!

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Sorry for the late review.

@ota-meshi ota-meshi merged commit 3e66445 into vuejs:master Nov 29, 2023
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

Successfully merging this pull request may close these issues.

Add type-literal as an option for vue/define-emits-declaration
3 participants