Performance: Typing emits
MEDIUM IMPACT
Typing emits affects how Vue components communicate events, impacting runtime checks and bundle size.
import { defineComponent } from 'vue'; export default defineComponent({ emits: { update: (payload: number) => typeof payload === 'number' }, methods: { sendUpdate() { this.$emit('update', 123); } } });
export default { emits: ['update'], methods: { sendUpdate() { this.$emit('update', 123); } } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Untyped emits | No direct DOM ops | 0 | 0 | [!] OK |
| Typed emits with validation | No direct DOM ops | 0 | 0 | [OK] Good |