Skip to content

chore: tidy up #10874

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 1 commit into from
Mar 22, 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/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { reconcile_html, remove } from '../reconciler.js';
* @returns {void}
*/
export function html(dom, get_value, svg) {
/** @type {import('#client').TemplateNode | import('#client').TemplateNode[]} */
/** @type {import('#client').Dom} */
let html_dom;

/** @type {string} */
Expand Down
8 changes: 4 additions & 4 deletions packages/svelte/src/internal/client/dom/blocks/if.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { create_block } from './utils.js';
/**
* @param {Comment} anchor
* @param {() => boolean} get_condition
* @param {(anchor: Node) => import('#client').TemplateNode | import('#client').TemplateNode[]} consequent_fn
* @param {null | ((anchor: Node) => import('#client').TemplateNode | import('#client').TemplateNode[])} alternate_fn
* @param {(anchor: Node) => import('#client').Dom} consequent_fn
* @param {null | ((anchor: Node) => import('#client').Dom)} 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 @@ -27,10 +27,10 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els

hydrate_block_anchor(anchor);

/** @type {undefined | import('#client').TemplateNode | Array<import('#client').TemplateNode>} */
/** @type {undefined | import('#client').Dom} */
let consequent_dom;

/** @type {undefined | import('#client').TemplateNode | Array<import('#client').TemplateNode>} */
/** @type {undefined | import('#client').Dom} */
let alternate_dom;

/** @type {import('#client').Effect | null} */
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/internal/client/dom/reconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function create_fragment_with_script_from_html(html) {
}

/**
* @param {Array<import('../types.js').TemplateNode> | import('../types.js').TemplateNode} current
* @param {import('#client').Dom} current
* @param {Text | Element | Comment} sibling
* @returns {Text | Element | Comment}
*/
Expand All @@ -49,7 +49,7 @@ export function insert(current, sibling) {
}

/**
* @param {Array<import('../types.js').TemplateNode> | import('../types.js').TemplateNode} current
* @param {import('#client').Dom} current
*/
export function remove(current) {
if (is_array(current)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/internal/client/dom/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ export function comment(anchor) {
* @param {Element | Text} dom
* @param {boolean} is_fragment
* @param {null | Text | Comment | Element} anchor
* @returns {import('#client').TemplateNode | import('#client').TemplateNode[]}
* @returns {import('#client').Dom}
*/
function close_template(dom, is_fragment, anchor) {
/** @type {import('#client').TemplateNode | Array<import('#client').TemplateNode>} */
/** @type {import('#client').Dom} */
var current = is_fragment
? is_array(dom)
? dom
Expand Down
15 changes: 4 additions & 11 deletions packages/svelte/src/internal/client/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ export type Equals = (this: Value, value: unknown) => boolean;

export type TemplateNode = Text | Element | Comment;

export type Dom = TemplateNode | TemplateNode[];

export interface Block {
/** dom */
d: null | TemplateNode | Array<TemplateNode>;
d: null | Dom;
}

export type EachState = {
Expand All @@ -65,7 +67,7 @@ export type EachItem = {
/** animation manager */
a: AnimationManager | null;
/** dom */
d: null | TemplateNode | Array<TemplateNode>;
d: null | Dom;
/** effect */
e: Effect;
/** item */
Expand Down Expand Up @@ -139,15 +141,6 @@ export type StoreReferencesContainer = Record<

export type ActionPayload<P> = { destroy?: () => void; update?: (value: P) => void };

export type Render = {
/** dom */
d: null | TemplateNode | Array<TemplateNode>;
/** effect */
e: null | Effect;
/** prev */
p: Render | null;
};

export type Raf = {
/** Alias for `requestAnimationFrame`, exposed in such a way that we can override in tests */
tick: (callback: (time: DOMHighResTimeStamp) => void) => any;
Expand Down