Skip to content

chore: use JSDoc import #12595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/dom/blocks/each.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function index(_, i) {
* @param {EachState} state
* @param {EachItem[]} items
* @param {null | Node} controlled_anchor
* @param {Map<any, import("#client").EachItem>} items_map
* @param {Map<any, EachItem>} items_map
*/
function pause_effects(state, items, controlled_anchor, items_map) {
/** @type {TransitionManager[]} */
Expand Down
10 changes: 5 additions & 5 deletions packages/svelte/src/internal/client/dom/blocks/if.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @import { TemplateNode } from '#client' */
/** @import { Effect, TemplateNode } from '#client' */
import { EFFECT_TRANSPARENT } from '../../constants.js';
import {
hydrate_next,
Expand All @@ -14,8 +14,8 @@ import { HYDRATION_START_ELSE } from '../../../../constants.js';
/**
* @param {TemplateNode} node
* @param {() => boolean} get_condition
* @param {(anchor: Node) => import('#client').Dom} consequent_fn
* @param {null | ((anchor: Node) => import('#client').Dom)} [alternate_fn]
* @param {(anchor: Node) => void} consequent_fn
* @param {null | ((anchor: Node) => void)} [alternate_fn]
* @param {boolean} [elseif] True if this is an `{:else if ...}` block rather than an `{#if ...}`, as that affects which transitions are considered 'local'
* @returns {void}
*/
Expand All @@ -26,10 +26,10 @@ export function if_block(node, get_condition, consequent_fn, alternate_fn = null

var anchor = node;

/** @type {import('#client').Effect | null} */
/** @type {Effect | null} */
var consequent_effect = null;

/** @type {import('#client').Effect | null} */
/** @type {Effect | null} */
var alternate_effect = null;

/** @type {boolean | null} */
Expand Down
33 changes: 17 additions & 16 deletions packages/svelte/src/internal/client/dom/elements/transitions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @import { AnimateFn, Animation, AnimationConfig, EachItem, Effect, Task, TransitionFn, TransitionManager } from '#client' */
import { noop, is_function } from '../../../shared/utils.js';
import { effect } from '../../reactivity/effects.js';
import { current_effect, untrack } from '../../runtime.js';
Expand Down Expand Up @@ -60,19 +61,19 @@ const linear = (t) => t;
* and attaches it to the block, so that moves can be animated following reconciliation.
* @template P
* @param {Element} element
* @param {() => import('#client').AnimateFn<P | undefined>} get_fn
* @param {() => AnimateFn<P | undefined>} get_fn
* @param {(() => P) | null} get_params
*/
export function animation(element, get_fn, get_params) {
var item = /** @type {import('#client').EachItem} */ (current_each_item);
var item = /** @type {EachItem} */ (current_each_item);

/** @type {DOMRect} */
var from;

/** @type {DOMRect} */
var to;

/** @type {import('#client').Animation | undefined} */
/** @type {Animation | undefined} */
var animation;

/** @type {null | { position: string, width: string, height: string, transform: string }} */
Expand Down Expand Up @@ -167,7 +168,7 @@ export function animation(element, get_fn, get_params) {
* @template P
* @param {number} flags
* @param {HTMLElement} element
* @param {() => import('#client').TransitionFn<P | undefined>} get_fn
* @param {() => TransitionFn<P | undefined>} get_fn
* @param {(() => P) | null} get_params
* @returns {void}
*/
Expand All @@ -180,15 +181,15 @@ export function transition(flags, element, get_fn, get_params) {
/** @type {'in' | 'out' | 'both'} */
var direction = is_both ? 'both' : is_intro ? 'in' : 'out';

/** @type {import('#client').AnimationConfig | ((opts: { direction: 'in' | 'out' }) => import('#client').AnimationConfig) | undefined} */
/** @type {AnimationConfig | ((opts: { direction: 'in' | 'out' }) => AnimationConfig) | undefined} */
var current_options;

var inert = element.inert;

/** @type {import('#client').Animation | undefined} */
/** @type {Animation | undefined} */
var intro;

/** @type {import('#client').Animation | undefined} */
/** @type {Animation | undefined} */
var outro;

/** @type {(() => void) | undefined} */
Expand All @@ -201,7 +202,7 @@ export function transition(flags, element, get_fn, get_params) {
return (current_options ??= get_fn()(element, get_params?.(), { direction }));
}

/** @type {import('#client').TransitionManager} */
/** @type {TransitionManager} */
var transition = {
is_global,
in() {
Expand Down Expand Up @@ -271,7 +272,7 @@ export function transition(flags, element, get_fn, get_params) {
}
};

var e = /** @type {import('#client').Effect} */ (current_effect);
var e = /** @type {Effect} */ (current_effect);

(e.transitions ??= []).push(transition);

Expand All @@ -282,7 +283,7 @@ export function transition(flags, element, get_fn, get_params) {
let run = is_global;

if (!run) {
var block = /** @type {import('#client').Effect | null} */ (e.parent);
var block = /** @type {Effect | null} */ (e.parent);

// skip over transparent blocks (e.g. snippets, else-if blocks)
while (block && (block.f & EFFECT_TRANSPARENT) !== 0) {
Expand All @@ -305,12 +306,12 @@ export function transition(flags, element, get_fn, get_params) {
/**
* Animates an element, according to the provided configuration
* @param {Element} element
* @param {import('#client').AnimationConfig | ((opts: { direction: 'in' | 'out' }) => import('#client').AnimationConfig)} options
* @param {import('#client').Animation | undefined} counterpart The corresponding intro/outro to this outro/intro
* @param {AnimationConfig | ((opts: { direction: 'in' | 'out' }) => AnimationConfig)} options
* @param {Animation | undefined} counterpart The corresponding intro/outro to this outro/intro
* @param {number} t2 The target `t` value — `1` for intro, `0` for outro
* @param {(() => void) | undefined} on_finish Called after successfully completing the animation
* @param {(() => void) | undefined} on_abort Called if the animation is aborted
* @returns {import('#client').Animation}
* @returns {Animation}
*/
function animate(element, options, counterpart, t2, on_finish, on_abort) {
var is_intro = t2 === 1;
Expand All @@ -319,7 +320,7 @@ function animate(element, options, counterpart, t2, on_finish, on_abort) {
// In the case of a deferred transition (such as `crossfade`), `option` will be
// a function rather than an `AnimationConfig`. We need to call this function
// once DOM has been updated...
/** @type {import('#client').Animation} */
/** @type {Animation} */
var a;

queue_micro_task(() => {
Expand Down Expand Up @@ -358,10 +359,10 @@ function animate(element, options, counterpart, t2, on_finish, on_abort) {
var duration = options.duration * Math.abs(delta);
var end = start + duration;

/** @type {Animation} */
/** @type {globalThis.Animation} */
var animation;

/** @type {import('#client').Task} */
/** @type {Task} */
var task;

if (css) {
Expand Down
15 changes: 8 additions & 7 deletions packages/svelte/src/internal/client/reactivity/deriveds.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @import { Derived } from '#client' */
import { CLEAN, DERIVED, DESTROYED, DIRTY, MAYBE_DIRTY, UNOWNED } from '../constants.js';
import {
current_reaction,
Expand All @@ -16,14 +17,14 @@ export let updating_derived = false;
/**
* @template V
* @param {() => V} fn
* @returns {import('#client').Derived<V>}
* @returns {Derived<V>}
*/
/*#__NO_SIDE_EFFECTS__*/
export function derived(fn) {
let flags = DERIVED | DIRTY;
if (current_effect === null) flags |= UNOWNED;

/** @type {import('#client').Derived<V>} */
/** @type {Derived<V>} */
const signal = {
deps: null,
deriveds: null,
Expand All @@ -38,7 +39,7 @@ export function derived(fn) {
};

if (current_reaction !== null && (current_reaction.f & DERIVED) !== 0) {
var current_derived = /** @type {import('#client').Derived} */ (current_reaction);
var current_derived = /** @type {Derived} */ (current_reaction);
if (current_derived.deriveds === null) {
current_derived.deriveds = [signal];
} else {
Expand All @@ -52,7 +53,7 @@ export function derived(fn) {
/**
* @template V
* @param {() => V} fn
* @returns {import('#client').Derived<V>}
* @returns {Derived<V>}
*/
/*#__NO_SIDE_EFFECTS__*/
export function derived_safe_equal(fn) {
Expand All @@ -62,7 +63,7 @@ export function derived_safe_equal(fn) {
}

/**
* @param {import('#client').Derived} derived
* @param {Derived} derived
* @returns {void}
*/
function destroy_derived_children(derived) {
Expand All @@ -79,7 +80,7 @@ function destroy_derived_children(derived) {
}

/**
* @param {import('#client').Derived} derived
* @param {Derived} derived
* @returns {void}
*/
export function update_derived(derived) {
Expand All @@ -103,7 +104,7 @@ export function update_derived(derived) {
}

/**
* @param {import('#client').Derived} signal
* @param {Derived} signal
* @returns {void}
*/
export function destroy_derived(signal) {
Expand Down
Loading
Loading