From 3191147c2acf52ecf9add8240db6d9c7ac04754e Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Wed, 20 Sep 2023 13:44:38 +0545 Subject: [PATCH] chore: document init parameters (#9118) --- .../svelte/src/runtime/internal/Component.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/svelte/src/runtime/internal/Component.js b/packages/svelte/src/runtime/internal/Component.js index 2bfdb6fd48..88f048c6ee 100644 --- a/packages/svelte/src/runtime/internal/Component.js +++ b/packages/svelte/src/runtime/internal/Component.js @@ -84,7 +84,17 @@ function make_dirty(component, i) { component.$$.dirty[(i / 31) | 0] |= 1 << i % 31; } -/** @returns {void} */ +// TODO: Document the other params +/** + * @param {SvelteComponent} component + * @param {import('./public.js').ComponentConstructorOptions} options + * + * @param {import('./utils.js')['not_equal']} not_equal Used to compare props and state values. + * @param {(target: Element | ShadowRoot) => void} [append_styles] Function that appends styles to the DOM when the component is first initialised. + * This will be the `add_css` function from the compiled component. + * + * @returns {void} + */ export function init( component, options, @@ -92,7 +102,7 @@ export function init( create_fragment, not_equal, props, - append_styles, + append_styles = null, dirty = [-1] ) { const parent_component = current_component; @@ -139,8 +149,9 @@ export function init( if (options.target) { if (options.hydrate) { start_hydrating(); + // TODO: what is the correct type here? + // @ts-expect-error const nodes = children(options.target); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion $$.fragment && $$.fragment.l(nodes); nodes.forEach(detach); } else {