From 0545dbf5343ccf1065103d2df8a2cefe75f8c811 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 22 Feb 2024 10:42:40 -0500 Subject: [PATCH] some type stuff --- .../svelte/src/internal/client/dom/blocks/each.js | 13 +++++++++---- packages/svelte/src/internal/client/types.d.ts | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/svelte/src/internal/client/dom/blocks/each.js b/packages/svelte/src/internal/client/dom/blocks/each.js index b786382a83..2a9505314d 100644 --- a/packages/svelte/src/internal/client/dom/blocks/each.js +++ b/packages/svelte/src/internal/client/dom/blocks/each.js @@ -80,6 +80,7 @@ export function create_each_item_block(item, index, key) { // dom d: null, // effect + // @ts-expect-error e: null, // index i: index, @@ -353,7 +354,7 @@ export function each_keyed(anchor_node, collection, flags, key_fn, render_fn, fa * @param {Element | Comment} anchor_node * @param {() => V[]} collection * @param {number} flags - * @param {(anchor: null, item: V, index: import('../../types.js').MaybeSignal) => void} render_fn + * @param {(anchor: Element | Comment | null, item: V, index: import('../../types.js').MaybeSignal) => void} render_fn * @param {null | ((anchor: Node) => void)} fallback_fn * @returns {void} */ @@ -402,8 +403,9 @@ export function each_indexed(anchor_node, collection, flags, render_fn, fallback let hydrating_node = hydrating ? current_hydration_fragment[0] : null; for (let i = length; i < nl; i += 1) { - if (effects[i]) { - resume_effect(effects[i]); + const effect = effects[i]; + if (effect) { + resume_effect(effect); } else { if (hydrating && !mismatch) { let fragment = get_hydration_fragment(hydrating_node); @@ -416,7 +418,10 @@ export function each_indexed(anchor_node, collection, flags, render_fn, fallback break; } - hydrating_node = fragment.at(-1).nextSibling?.nextSibling; + // TODO helperise this + hydrating_node = /** @type {Comment} */ ( + /** @type {Node} */ (fragment.at(-1)).nextSibling?.nextSibling + ); } effects[i] = render_effect( diff --git a/packages/svelte/src/internal/client/types.d.ts b/packages/svelte/src/internal/client/types.d.ts index 06b015be98..98d56d80f4 100644 --- a/packages/svelte/src/internal/client/types.d.ts +++ b/packages/svelte/src/internal/client/types.d.ts @@ -301,7 +301,7 @@ export type EachItemBlock = { /** dom */ d: null | TemplateNode | Array; /** effect */ - e: null | ComputationSignal; + e: ComputationSignal; /** item */ v: any | Signal; /** index */