Home / Function/ generic_fn() — svelte Function Reference

generic_fn() — svelte Function Reference

Architecture documentation for the generic_fn() function in create-event-dispatcher.ts from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  178d5797_c477_b2e7_7804_dd70ff3c8153["generic_fn()"]
  f9745fad_1100_e24d_5c32_c1e7ed4341f5["create-event-dispatcher.ts"]
  178d5797_c477_b2e7_7804_dd70ff3c8153 -->|defined in| f9745fad_1100_e24d_5c32_c1e7ed4341f5
  style 178d5797_c477_b2e7_7804_dd70ff3c8153 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/tests/types/create-event-dispatcher.ts lines 45–63

function generic_fn<T extends boolean>(t: T) {
	const dispatch = createEventDispatcher<{
		required: T;
		optional: T | null;
	}>();

	dispatch('required', t);
	dispatch('optional', t);
	dispatch('optional', null);
	dispatch('optional', undefined);
	// @ts-expect-error: wrong type of optional detail
	dispatch('optional', 'string');
	// @ts-expect-error: wrong type of required detail
	dispatch('required', 'string');
	// @ts-expect-error: wrong type of optional detail
	dispatch('optional', true);
	// @ts-expect-error: wrong type of required detail
	dispatch('required', true);
}

Domain

Subdomains

Frequently Asked Questions

What does generic_fn() do?
generic_fn() is a function in the svelte codebase, defined in packages/svelte/tests/types/create-event-dispatcher.ts.
Where is generic_fn() defined?
generic_fn() is defined in packages/svelte/tests/types/create-event-dispatcher.ts at line 45.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free