Home / File/ create-event-dispatcher.ts — svelte Source File

create-event-dispatcher.ts — svelte Source File

Architecture documentation for create-event-dispatcher.ts, a typescript file in the svelte codebase. 1 imports, 0 dependents.

File typescript BuildSystem QualityControl 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  f9745fad_1100_e24d_5c32_c1e7ed4341f5["create-event-dispatcher.ts"]
  4ead6623_c53e_ab40_5690_64903d5addf1["svelte"]
  f9745fad_1100_e24d_5c32_c1e7ed4341f5 --> 4ead6623_c53e_ab40_5690_64903d5addf1
  style f9745fad_1100_e24d_5c32_c1e7ed4341f5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { createEventDispatcher } from 'svelte';

const dispatch = createEventDispatcher<{
	loaded: null;
	change: string;
	valid: boolean;
	optional: number | null;
}>();

// @ts-expect-error: dispatch invalid event
dispatch('some-event');

dispatch('loaded');
dispatch('loaded', null);
dispatch('loaded', undefined);
dispatch('loaded', undefined, { cancelable: true });
// @ts-expect-error: no detail accepted
dispatch('loaded', 123);

// @ts-expect-error: detail not provided
dispatch('change');
dispatch('change', 'string');
dispatch('change', 'string', { cancelable: true });
// @ts-expect-error: wrong type of detail
dispatch('change', 123);
// @ts-expect-error: wrong type of detail
dispatch('change', undefined);

dispatch('valid', true);
dispatch('valid', true, { cancelable: true });
// @ts-expect-error: wrong type of detail
dispatch('valid', 'string');

dispatch('optional');
dispatch('optional', 123);
dispatch('optional', 123, { cancelable: true });
dispatch('optional', null);
dispatch('optional', undefined);
dispatch('optional', undefined, { cancelable: true });
// @ts-expect-error: wrong type of optional detail
dispatch('optional', 'string');
// @ts-expect-error: wrong type of option
dispatch('optional', undefined, { cancelabled: true });

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);
}
generic_fn;

Domain

Subdomains

Functions

Dependencies

  • svelte

Frequently Asked Questions

What does create-event-dispatcher.ts do?
create-event-dispatcher.ts is a source file in the svelte codebase, written in typescript. It belongs to the BuildSystem domain, QualityControl subdomain.
What functions are defined in create-event-dispatcher.ts?
create-event-dispatcher.ts defines 1 function(s): generic_fn.
What does create-event-dispatcher.ts depend on?
create-event-dispatcher.ts imports 1 module(s): svelte.
Where is create-event-dispatcher.ts in the architecture?
create-event-dispatcher.ts is located at packages/svelte/tests/types/create-event-dispatcher.ts (domain: BuildSystem, subdomain: QualityControl, directory: packages/svelte/tests/types).

Analyze Your Own Codebase

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

Try Supermodel Free