Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.47 KB

require-emit-types.md

File metadata and controls

61 lines (45 loc) · 1.47 KB
pageClass sidebarDepth title description
rule-details
0
vue/require-emit-types
require type definitions in emits

vue/require-emit-types

require type definitions in emits

  • This rule has not been released yet.
  • ⚙️ This rule is included in "plugin:vue/vue3-strongly-recommended" and "plugin:vue/vue3-recommended".

📖 Rule Details

This rule enforces that a emits statement contains type definition.

Declaring emits with types can bring better maintenance. Even if using with TypeScript, this can provide better type inference when annotating parameters with types.

<script>
/* ✓ GOOD */
Vue.component('foo', {
  emits: {
    // Emit with arguments
    foo: (payload) => { /* validate payload */ },
    // Emit without parameters
    bar: () => true,
  }
})

/* ✗ BAD */
Vue.component('bar', {
  emits: ['foo']
})

Vue.component('baz', {
  emits: {
    foo: null,
  }
})
</script>

🔧 Options

Nothing.

📚 Further Reading

🔍 Implementation