Home / File/ public.d.ts — svelte Source File

public.d.ts — svelte Source File

Architecture documentation for public.d.ts, a typescript file in the svelte codebase.

Entity Profile

Source Code

// Once https://github.com/microsoft/TypeScript/issues/59980 is fixed we can put these overloads into the JSDoc comments of the `on` function

/**
 * Attaches an event handler to the window and returns a function that removes the handler. Using this
 * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
 * (with attributes like `onclick`), which use event delegation for performance reasons
 */
export function on<Type extends keyof WindowEventMap>(
	window: Window,
	type: Type,
	handler: (this: Window, event: WindowEventMap[Type] & { currentTarget: Window }) => any,
	options?: AddEventListenerOptions | undefined
): () => void;
/**
 * Attaches an event handler to the document and returns a function that removes the handler. Using this
 * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
 * (with attributes like `onclick`), which use event delegation for performance reasons
 */
export function on<Type extends keyof DocumentEventMap>(
	document: Document,
	type: Type,
	handler: (this: Document, event: DocumentEventMap[Type] & { currentTarget: Document }) => any,
	options?: AddEventListenerOptions | undefined
): () => void;
/**
 * Attaches an event handler to an element and returns a function that removes the handler. Using this
 * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
 * (with attributes like `onclick`), which use event delegation for performance reasons
 */
export function on<Element extends HTMLElement, Type extends keyof HTMLElementEventMap>(
	element: Element,
	type: Type,
	handler: (this: Element, event: HTMLElementEventMap[Type] & { currentTarget: Element }) => any,
	options?: AddEventListenerOptions | undefined
): () => void;
/**
 * Attaches an event handler to an element and returns a function that removes the handler. Using this
 * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
 * (with attributes like `onclick`), which use event delegation for performance reasons
 */
export function on<Element extends MediaQueryList, Type extends keyof MediaQueryListEventMap>(
	element: Element,
	type: Type,
	handler: (this: Element, event: MediaQueryListEventMap[Type] & { currentTarget: Element }) => any,
	options?: AddEventListenerOptions | undefined
): () => void;
/**
 * Attaches an event handler to an element and returns a function that removes the handler. Using this
 * rather than `addEventListener` will preserve the correct order relative to handlers added declaratively
 * (with attributes like `onclick`), which use event delegation for performance reasons
 */
export function on(
	element: EventTarget,
	type: string,
	handler: EventListener,
	options?: AddEventListenerOptions | undefined
): () => void;

Frequently Asked Questions

What does public.d.ts do?
public.d.ts is a source file in the svelte codebase, written in typescript.
Where is public.d.ts in the architecture?
public.d.ts is located at packages/svelte/src/events/public.d.ts (directory: packages/svelte/src/events).

Analyze Your Own Codebase

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

Try Supermodel Free