import { SvelteComponent } from './Component.js'; import { SvelteComponentDev } from './dev.js'; export interface ComponentConstructorOptions< Props extends Record = Record > { target: Element | Document | ShadowRoot; anchor?: Element; props?: Props; context?: Map; hydrate?: boolean; intro?: boolean; $$inline?: boolean; } /** * Convenience type to get the events the given component expects. Example: * ```html * * * * ``` */ export type ComponentEvents = Component extends SvelteComponentDev ? Events : never; /** * Convenience type to get the props the given component expects. Example: * ```html * * ``` */ export type ComponentProps = Component extends SvelteComponentDev ? Props : never; /** * Convenience type to get the type of a Svelte component. Useful for example in combination with * dynamic components using ``. * * Example: * ```html * * * * * ``` */ export type ComponentType = (new ( options: ComponentConstructorOptions< Component extends SvelteComponentDev ? Props : Record > ) => Component) & { /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ element?: typeof HTMLElement; }; export interface DispatchOptions { cancelable?: boolean; } export interface EventDispatcher> { // Implementation notes: // - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode // - | null | undefined is added for convenience, as they are equivalent for the custom event constructor (both result in a null detail) ( ...args: null extends EventMap[Type] ? [type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions] : undefined extends EventMap[Type] ? [type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions] : [type: Type, parameter: EventMap[Type], options?: DispatchOptions] ): boolean; }