Skip to content

Files

Latest commit

 

History

History
32 lines (23 loc) · 721 Bytes

define-emits-declaration.md

File metadata and controls

32 lines (23 loc) · 721 Bytes

Pattern: Inconsistent defineEmits style

Issue: -

Description

This rule enforces defineEmits typing style which you should use type-based or runtime declaration.

This rule only works in setup script and lang="ts".

<script setup lang="ts">
/* ✓ GOOD */
const emit = defineEmits<{
  (e: 'change', id: number): void
  (e: 'update', value: string): void
}>()

/* ✗ BAD */
const emit = defineEmits({
  change: (id) => typeof id == 'number',
  update: (value) => typeof value == 'string'
})

/* ✗ BAD */
const emit = defineEmits(['change', 'update'])
</script>

Further Reading