Skip to content

Commit 399bda5

Browse files
committed
lint
1 parent d7f580d commit 399bda5

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function AwaitExpression(node, context) {
2626
// @ts-expect-error we could probably use a neater/more robust mechanism
2727
if (parent.metadata) break;
2828

29-
// TODO make this more accurate — we don't need to call suspend
29+
// TODO make this more accurate — we don't need to call suspend
3030
// if this is the last thing that could be read
3131
preserve_context = true;
3232
}

packages/svelte/src/internal/client/dom/blocks/each.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
283283
update_item(existing, value, i, flags);
284284
}
285285
} else {
286-
var item = create_item(
286+
item = create_item(
287287
null,
288288
state,
289289
null,

packages/svelte/src/internal/client/reactivity/batch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,17 @@ export class Batch {
130130
batches.delete(this);
131131

132132
for (var batch of batches) {
133+
/** @type {Source} */
134+
var source;
135+
133136
if (batch.#id < this.#id) {
134137
// other batch is older than this
135-
for (var source of this.#previous.keys()) {
138+
for (source of this.#previous.keys()) {
136139
batch.#previous.delete(source);
137140
}
138141
} else {
139142
// other batch is newer than this
140-
for (var source of batch.#previous.keys()) {
143+
for (source of batch.#previous.keys()) {
141144
if (this.#previous.has(source)) {
142145
batch.#previous.set(source, source.v);
143146
}

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function derived(fn) {
8989

9090
/**
9191
* @template V
92-
* @param {() => Promise<V>} fn
92+
* @param {() => V | Promise<V>} fn
9393
* @param {string} [location] If provided, print a warning if the value is not read immediately after update
9494
* @returns {Promise<Source<V>>}
9595
*/
@@ -173,12 +173,21 @@ export function async_derived(fn, location) {
173173
);
174174
}, EFFECT_ASYNC | EFFECT_PRESERVED);
175175

176-
return new Promise(async (fulfil) => {
177-
// if the effect re-runs before the initial promise
178-
// resolves, delay resolution until we have a value
179-
var p;
180-
while (p !== (p = promise)) await p;
181-
fulfil(signal);
176+
return new Promise((fulfil) => {
177+
/** @param {Promise<V>} p */
178+
function next(p) {
179+
p.then(() => {
180+
if (p === promise) {
181+
fulfil(signal);
182+
} else {
183+
// if the effect re-runs before the initial promise
184+
// resolves, delay resolution until we have a value
185+
next(promise);
186+
}
187+
});
188+
}
189+
190+
next(promise);
182191
});
183192
}
184193

0 commit comments

Comments
 (0)