# svelte/require-event-dispatcher-types

require type parameters for createEventDispatcher

# 📖 Rule Details

This rule is aimed to enforce type parameters when calling createEventDispatcher. Adding types makes all dispatch calls as well as all event listeners typechecked. For more information, see the svelte docs.

<script lang="ts">
  /* eslint svelte/require-event-dispatcher-types: "error" */

  import { createEventDispatcher } from 'svelte';

  /* ✓ GOOD */
  const dispatch1 = createEventDispatcher<{ one: never; two: number }>();
  const dispatch2 = createEventDispatcher<Record<string, never>>();
  const dispatch3 = createEventDispatcher<any>();
  const dispatch4 = createEventDispatcher<unknown>();

  /* ✗ BAD */
  const dispatch5 = createEventDispatcher();
</script>

# 🔧 Options

Nothing.

# 🚀 Version

This rule was introduced in eslint-plugin-svelte v2.16.0

# 🔍 Implementation