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

fix(types): defineEmits w/ interface declaration #12343

Merged
merged 1 commit into from
Nov 15, 2024
Merged

Conversation

edison1105
Copy link
Member

close #8457

Copy link

github-actions bot commented Nov 7, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 38 kB 34.2 kB
vue.global.prod.js 159 kB 57.9 kB 51.4 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.9 kB 18.3 kB 16.7 kB
createApp 55 kB 21.3 kB 19.4 kB
createSSRApp 59 kB 23 kB 21 kB
defineCustomElement 59.8 kB 22.8 kB 20.8 kB
overall 68.7 kB 26.3 kB 24 kB

Copy link

pkg-pr-new bot commented Nov 7, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12343

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12343

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12343

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12343

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12343

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12343

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12343

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12343

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12343

vue

pnpm add https://pkg.pr.new/vue@12343

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12343

commit: c4e9b3f

@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: types labels Nov 7, 2024
@yyx990803
Copy link
Member

This widens the type constraint for the interface, but I think it's worth it.

If the user writes something like

interface Emits {
  bar: 1 // !!!!
}

Now it will be allowed, but the emit function will expect ...args to be of type 1, which will never be satisfied, so that serves as a safeguard against misuse.

@yyx990803 yyx990803 merged commit 1022eab into main Nov 15, 2024
15 checks passed
@yyx990803 yyx990803 deleted the edison/fix/8457 branch November 15, 2024 02:47
noootwo pushed a commit to noootwo/core that referenced this pull request Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged. scope: types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use interface to declare emits
2 participants