feat: Define the MountOptions type

pull/13674/head
Ramirez Vargas, José Pablo 11 months ago
parent 0598f2bbe1
commit bd3596fcba

@ -379,26 +379,44 @@ declare module 'svelte' {
}): Snippet<Params>; }): Snippet<Params>;
/** Anything except a function */ /** Anything except a function */
type NotFunction<T> = T extends Function ? never : T; type NotFunction<T> = T extends Function ? never : T;
/** export type MountOptions<Props extends Record<string, any> = Record<string, any>> = {
* Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component. /**
* Transitions will play during the initial render unless the `intro` option is set to `false`. * Target element where the component will be mounted.
* */
* */
export function mount<Props extends Record<string, any>, Exports extends Record<string, any>>(component: ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>, options: {} extends Props ? {
target: Document | Element | ShadowRoot; target: Document | Element | ShadowRoot;
/**
* Optional node inside `target` and when specified, it is used to render the component immediately before it.
*/
anchor?: Node; anchor?: Node;
props?: Props; /**
* Allows the specification of events.
*/
events?: Record<string, (e: any) => any>; events?: Record<string, (e: any) => any>;
/**
* Used to define context at the component level.
*/
context?: Map<any, any>; context?: Map<any, any>;
/**
* Used to control transition playback on initial render. The default value is `true` to run transitions.
*/
intro?: boolean; intro?: boolean;
} & {} extends Props ? {
/**
* Component properties.
*/
props?: Props;
} : { } : {
target: Document | Element | ShadowRoot; /**
* Component properties.
*/
props: Props; props: Props;
anchor?: Node; }
events?: Record<string, (e: any) => any>; /**
context?: Map<any, any>; * Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component.
intro?: boolean; * Transitions will play during the initial render unless the `intro` option is set to `false`.
}): Exports; *
* */
export function mount<Props extends Record<string, any>, Exports extends Record<string, any>>(component: ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>, options: MountOptions<Props>): Exports;
/** /**
* Hydrates a component on the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component * Hydrates a component on the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component
* *

Loading…
Cancel
Save