diff --git a/src/runtime/action/index.d.ts b/src/runtime/action/index.d.ts new file mode 100644 index 0000000000..b36a8d82ce --- /dev/null +++ b/src/runtime/action/index.d.ts @@ -0,0 +1,76 @@ +/** + * Actions can return an object containing the two properties defined in this interface. Both are optional. + * - update: An action can have a parameter. This method will be called whenever that parameter changes, + * immediately after Svelte has applied updates to the markup. `ActionReturn` and `ActionReturn` both + * mean that the action accepts no parameters, which makes it illegal to set the `update` method. + * - destroy: Method that is called after the element is unmounted + * + * Additionally, you can specify which additional attributes and events the action enables on the applied element. + * This applies to TypeScript typings only and has no effect at runtime. + * + * Example usage: + * ```ts + * interface Attributes { + * newprop?: string; + * 'on:event': (e: CustomEvent) => void; + * } + * + * export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn { + * // ... + * return { + * update: (updatedParameter) => {...}, + * destroy: () => {...} + * }; + * } + * ``` + * + * Docs: https://svelte.dev/docs#template-syntax-element-directives-use-action + */ +export interface ActionReturn< + Parameter = never, + Attributes extends Record = Record +> { + update?: [Parameter] extends [never] ? never : (parameter: Parameter) => void; + destroy?: () => void; + /** + * ### DO NOT USE THIS + * This exists solely for type-checking and has no effect at runtime. + * Set this through the `Attributes` generic instead. + */ + $$_attributes?: Attributes; +} + +/** + * Actions are functions that are called when an element is created. + * You can use this interface to type such actions. + * The following example defines an action that only works on `
` elements + * and optionally accepts a parameter which it has a default value for: + * ```ts + * export const myAction: Action = (node, param = { someProperty: true }) => { + * // ... + * } + * ``` + * `Action` and `Action` both signal that the action accepts no parameters. + * + * You can return an object with methods `update` and `destroy` from the function and type which additional attributes and events it has. + * See interface `ActionReturn` for more details. + * + * Docs: https://svelte.dev/docs#template-syntax-element-directives-use-action + */ +export interface Action< + Element = HTMLElement, + Parameter = never, + Attributes extends Record = Record +> { + ( + ...args: [Parameter] extends [never] + ? [node: Node] + : undefined extends Parameter + ? [node: Node, parameter?: Parameter] + : [node: Node, parameter: Parameter] + ): void | ActionReturn; +} + +// Implementation notes: +// - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode +// - [X] extends [never] is needed, X extends never would reduce the whole resulting type to never and not to one of the condition outcomes diff --git a/src/runtime/action/index.js b/src/runtime/action/index.js index 85b98ccc90..cb0ff5c3b5 100644 --- a/src/runtime/action/index.js +++ b/src/runtime/action/index.js @@ -1,59 +1 @@ export {}; - -// Implementation notes: -// - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode -// - [X] extends [never] is needed, X extends never would reduce the whole resulting type to never and not to one of the condition outcomes - -/** - * Actions can return an object containing the two properties defined in this interface. Both are optional. - * - update: An action can have a parameter. This method will be called whenever that parameter changes, - * immediately after Svelte has applied updates to the markup. `ActionReturn` and `ActionReturn` both - * mean that the action accepts no parameters, which makes it illegal to set the `update` method. - * - destroy: Method that is called after the element is unmounted - * - * Additionally, you can specify which additional attributes and events the action enables on the applied element. - * This applies to TypeScript typings only and has no effect at runtime. - * - * Example usage: - * ```ts - * interface Attributes { - * newprop?: string; - * 'on:event': (e: CustomEvent) => void; - * } - * - * export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn { - * // ... - * return { - * update: (updatedParameter) => {...}, - * destroy: () => {...} - * }; - * } - * ``` - * - * Docs: https://svelte.dev/docs#template-syntax-element-directives-use-action - * @typedef {Object} ActionReturn - * @property {[Parameter] extends [never] ? never : (parameter: Parameter) => void} [update] - * @property {()=>void} [destroy] - * @property {Attributes} [$$_attributes] - * ### DO NOT USE THIS - * This exists solely for type-checking and has no effect at runtime. - * Set this through the `Attributes` generic instead. - */ -/** - * Actions are functions that are called when an element is created. - * You can use this interface to type such actions. - * The following example defines an action that only works on `
` elements - * and optionally accepts a parameter which it has a default value for: - * ```ts - * export const myAction: Action = (node, param = { someProperty: true }) => { - * // ... - * } - * ``` - * `Action` and `Action` both signal that the action accepts no parameters. - * - * You can return an object with methods `update` and `destroy` from the function and type which additional attributes and events it has. - * See interface `ActionReturn` for more details. - * - * Docs: https://svelte.dev/docs#template-syntax-element-directives-use-action - * @typedef {Object} Action - */ diff --git a/src/runtime/animate/index.d.ts b/src/runtime/animate/index.d.ts new file mode 100644 index 0000000000..8c8e5565ea --- /dev/null +++ b/src/runtime/animate/index.d.ts @@ -0,0 +1,14 @@ +// todo: same as Transition, should it be shared? +export interface AnimationConfig { + delay?: number; + duration?: number; + easing?: (t: number) => number; + css?: (t: number, u: number) => string; + tick?: (t: number, u: number) => void; +} + +export interface FlipParams { + delay?: number; + duration?: number | ((len: number) => number); + easing?: (t: number) => number; +} diff --git a/src/runtime/animate/index.js b/src/runtime/animate/index.js index cc47eab7a7..ee3bba030f 100644 --- a/src/runtime/animate/index.js +++ b/src/runtime/animate/index.js @@ -3,9 +3,9 @@ import { is_function } from '../internal'; /** * @param {Element} node - * @param {{ from: DOMRect; to: DOMRect }} - * @param {FlipParams} params - * @returns {import("/Users/elliottjohnson/dev/sveltejs/svelte/index.ts-to-jsdoc").AnimationConfig} + * @param {{ from: DOMRect; to: DOMRect }} fromTo + * @param {import('.').FlipParams} params + * @returns {import('.').AnimationConfig} */ export function flip(node, { from, to }, params = {}) { const style = getComputedStyle(node); @@ -27,19 +27,3 @@ export function flip(node, { from, to }, params = {}) { } }; } - -/** - * @typedef {Object} AnimationConfig - * @property {number} [delay] - * @property {number} [duration] - * @property {(t:number)=>number} [easing] - * @property {(t:number,u:number)=>string} [css] - * @property {(t:number,u:number)=>void} [tick] - */ - -/** - * @typedef {Object} FlipParams - * @property {number} [delay] - * @property {number|((len:number)=>number)} [duration] - * @property {(t:number)=>number} [easing] - */ diff --git a/src/runtime/internal/Component.js b/src/runtime/internal/Component.js index 4e99d2f2b5..8769286875 100644 --- a/src/runtime/internal/Component.js +++ b/src/runtime/internal/Component.js @@ -95,7 +95,7 @@ export function init( ) { const parent_component = current_component; set_current_component(component); - /** @type {import('.').T$$} */ + /** @type {import('./public.d.ts').T$$} */ const $$ = (component.$$ = { fragment: null, ctx: [], @@ -352,7 +352,7 @@ function get_custom_element_value(prop, value, props_definition, transform) { * @internal * * Turn a Svelte component into a custom element. - * @param {import('./dev').ComponentType} Component A Svelte component constructor + * @param {import('./public.d.ts').ComponentType} Component A Svelte component constructor * @param {Record} props_definition The props to observe * @param {string[]} slots The slots to create * @param {string[]} accessors Other accessors besides the ones for props the component has diff --git a/src/runtime/internal/ResizeObserverSingleton.js b/src/runtime/internal/ResizeObserverSingleton.js index ff71b22457..707356a40e 100644 --- a/src/runtime/internal/ResizeObserverSingleton.js +++ b/src/runtime/internal/ResizeObserverSingleton.js @@ -13,7 +13,7 @@ export class ResizeObserverSingleton { /** * @param {Element} element - * @param {Listener} listener + * @param {import('./private.d.ts').Listener} listener * @returns {() => void} */ observe(element, listener) { @@ -53,30 +53,3 @@ export class ResizeObserverSingleton { // Needs to be written like this to pass the tree-shake-test ResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined; - -/** @typedef {(entry: ResizeObserverEntry) => any} Listener */ -/** @typedef {'border-box' | 'content-box' | 'device-pixel-content-box'} ResizeObserverBoxOptions */ - -/** - * @typedef {Object} ResizeObserverSize - * @property {number} blockSize - * @property {number} inlineSize - */ - -/** - * @typedef {Object} ResizeObserverEntry - * @property {readonly ResizeObserverSize[]} borderBoxSize - * @property {readonly ResizeObserverSize[]} contentBoxSize - * @property {DOMRectReadOnly} contentRect - * @property {readonly ResizeObserverSize[]} devicePixelContentBoxSize - * @property {Element} target - */ - -/** - * @typedef {Object} ResizeObserverOptions - * @property {ResizeObserverBoxOptions} [box] - */ - -/** @typedef {Object} ResizeObserver */ - -/** @typedef {Object} ResizeObserverCallback */ diff --git a/src/runtime/internal/animations.js b/src/runtime/internal/animations.js index a2a42a8551..87b234fae1 100644 --- a/src/runtime/internal/animations.js +++ b/src/runtime/internal/animations.js @@ -5,8 +5,8 @@ import { create_rule, delete_rule } from './style_manager.js'; /** * @param {Element & ElementCSSInlineStyle} node - * @param {PositionRect} from - * @param {AnimationFn} fn + * @param {import('./private.d.ts').PositionRect} from + * @param {import('./private.d.ts').AnimationFn} fn * @returns {any} */ export function create_animation(node, from, fn, params) { @@ -88,7 +88,7 @@ export function fix_position(node) { /** * @param {Element & ElementCSSInlineStyle} node - * @param {PositionRect} a + * @param {import('./private.d.ts').PositionRect} a * @returns {void} */ export function add_transform(node, a) { @@ -99,12 +99,3 @@ export function add_transform(node, a) { node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`; } } - -/** @typedef {DOMRect | ClientRect} PositionRect */ -/** - * @typedef {( - * node: Element, - * { from, to }: { from: PositionRect; to: PositionRect }, - * params: any - * ) => import('../animate').AnimationConfig} AnimationFn - */ diff --git a/src/runtime/internal/await_block.js b/src/runtime/internal/await_block.js index 739b3c0977..ba70141cb7 100644 --- a/src/runtime/internal/await_block.js +++ b/src/runtime/internal/await_block.js @@ -6,13 +6,13 @@ import { get_current_component, set_current_component } from './lifecycle.js'; /** * @template T * @param {Promise} promise - * @param {PromiseInfo} info + * @param {import('./private.d.ts').PromiseInfo} info * @returns {boolean} */ export function handle_promise(promise, info) { const token = (info.token = {}); /** - * @param {import('.').FragmentFactory} type + * @param {import('./public.d.ts').FragmentFactory} type * @param {0 | 1 | 2} index * @param {number} [key] * @param {any} [value] @@ -98,22 +98,3 @@ export function update_await_block_branch(info, ctx, dirty) { } info.block.p(child_ctx, dirty); } - -/** - * @typedef {Object} PromiseInfo - * @template T - * @property {null|any} ctx - * @property {{}} token - * @property {boolean} hasCatch - * @property {FragmentFactory} pending - * @property {FragmentFactory} then - * @property {FragmentFactory} catch - * @property {number} value - * @property {number} error - * @property {T} [resolved] - * @property {FragmentFactory|null} current - * @property {Fragment|null} block - * @property {[null|Fragment,null|Fragment,null|Fragment]} blocks - * @property {()=>HTMLElement} mount - * @property {HTMLElement} anchor - */ diff --git a/src/runtime/internal/globals.js b/src/runtime/internal/globals.js index e2e3cc4257..15cf9ae259 100644 --- a/src/runtime/internal/globals.js +++ b/src/runtime/internal/globals.js @@ -1,2 +1,3 @@ +/** @type {typeof globalThis} */ export const globals = typeof window !== 'undefined' ? window : typeof globalThis !== 'undefined' ? globalThis : global; diff --git a/src/runtime/internal/index.d.ts b/src/runtime/internal/index.d.ts deleted file mode 100644 index c6ff30d066..0000000000 --- a/src/runtime/internal/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * INTERNAL, DO NOT USE. Code may change at any time. - */ -export interface Fragment { - key: string | null; - first: null; - /* create */ c: () => void; - /* claim */ l: (nodes: any) => void; - /* hydrate */ h: () => void; - /* mount */ m: (target: HTMLElement, anchor: any) => void; - /* update */ p: (ctx: T$$['ctx'], dirty: T$$['dirty']) => void; - /* measure */ r: () => void; - /* fix */ f: () => void; - /* animate */ a: () => void; - /* intro */ i: (local: any) => void; - /* outro */ o: (local: any) => void; - /* destroy */ d: (detaching: 0 | 1) => void; -} - -export type FragmentFactory = (ctx: any) => Fragment; - -export interface T$$ { - dirty: number[]; - ctx: any[]; - bound: any; - update: () => void; - callbacks: any; - after_update: any[]; - props: Record; - fragment: null | false | Fragment; - not_equal: any; - before_update: any[]; - context: Map; - on_mount: any[]; - on_destroy: any[]; - skip_bound: boolean; - on_disconnect: any[]; - root: Element | ShadowRoot; -} diff --git a/src/runtime/internal/lifecycle.d.ts b/src/runtime/internal/lifecycle.d.ts deleted file mode 100644 index 9e49fc4565..0000000000 --- a/src/runtime/internal/lifecycle.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -export interface EventDispatcher> { - // Implementation notes: - // - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode - // - [X] extends [never] is needed, X extends never would reduce the whole resulting type to never and not to one of the condition outcomes - ( - ...args: [EventMap[Type]] extends [never] - ? [type: Type, parameter?: null | undefined, options?: DispatchOptions] - : null extends EventMap[Type] - ? [type: Type, parameter?: EventMap[Type], options?: DispatchOptions] - : undefined extends EventMap[Type] - ? [type: Type, parameter?: EventMap[Type], options?: DispatchOptions] - : [type: Type, parameter: EventMap[Type], options?: DispatchOptions] - ): boolean; -} - -export interface DispatchOptions { - cancelable?: boolean; -} diff --git a/src/runtime/internal/lifecycle.js b/src/runtime/internal/lifecycle.js index def5586287..c054a6098c 100644 --- a/src/runtime/internal/lifecycle.js +++ b/src/runtime/internal/lifecycle.js @@ -92,7 +92,7 @@ export function onDestroy(fn) { * * https://svelte.dev/docs#run-time-svelte-createeventdispatcher * @template {Record} EventMap - * @returns {import('./lifecycle').EventDispatcher} + * @returns {import('./public.d.ts').EventDispatcher} */ export function createEventDispatcher() { const component = get_current_component(); @@ -175,9 +175,3 @@ export function bubble(component, event) { callbacks.slice().forEach((fn) => fn.call(this, event)); } } - -/** @typedef {Object} EventDispatcher */ -/** - * @typedef {Object} DispatchOptions - * @property {boolean} [cancelable] - */ diff --git a/src/runtime/internal/loop.js b/src/runtime/internal/loop.js index 67a30e5744..c5bde437d4 100644 --- a/src/runtime/internal/loop.js +++ b/src/runtime/internal/loop.js @@ -27,11 +27,11 @@ export function clear_loops() { /** * Creates a new task that runs on each raf frame * until it returns a falsy value or is aborted - * @param {TaskCallback} callback - * @returns {Task} + * @param {import('./private.d.ts').TaskCallback} callback + * @returns {import('./public.d.ts').Task} */ export function loop(callback) { - /** @type {TaskEntry} */ + /** @type {import('./private.d.ts').TaskEntry} */ let task; if (tasks.size === 0) raf(run_tasks); return { @@ -43,12 +43,3 @@ export function loop(callback) { } }; } - -/** @typedef {(now: number) => boolean | void} TaskCallback */ -/** @typedef {{ c: TaskCallback; f: () => void }} TaskEntry */ - -/** - * @typedef {Object} Task - * @property {() => void} abort - * @property {Promise} promise - */ diff --git a/src/runtime/internal/private.d.ts b/src/runtime/internal/private.d.ts new file mode 100644 index 0000000000..2ae88b3cc4 --- /dev/null +++ b/src/runtime/internal/private.d.ts @@ -0,0 +1,81 @@ +import type { AnimationConfig } from '../animate'; +import type { Fragment, FragmentFactory } from './public'; + +export type AnimationFn = ( + node: Element, + { from, to }: { from: PositionRect; to: PositionRect }, + params: any +) => AnimationConfig; + +type Listener = (entry: ResizeObserverEntry) => any; + +//todo: documentation says it is DOMRect, but in IE it would be ClientRect +export type PositionRect = DOMRect | ClientRect; + +export interface PromiseInfo { + ctx: null | any; + // unique object instance as a key to compare different promises + token: {}; + hasCatch: boolean; + pending: FragmentFactory; + then: FragmentFactory; + catch: FragmentFactory; + // ctx index for resolved value and rejected error + value: number; + error: number; + // resolved value or rejected error + resolved?: T; + // the current factory function for creating the fragment + current: FragmentFactory | null; + // the current fragment + block: Fragment | null; + // tuple of the pending, then, catch fragment + blocks: [null | Fragment, null | Fragment, null | Fragment]; + // DOM elements to mount and anchor on for the {#await} block + mount: () => HTMLElement; + anchor: HTMLElement; +} + +// TODO: Remove this +export interface ResizeObserverSize { + readonly blockSize: number; + readonly inlineSize: number; +} + +export interface ResizeObserverEntry { + readonly borderBoxSize: readonly ResizeObserverSize[]; + readonly contentBoxSize: readonly ResizeObserverSize[]; + readonly contentRect: DOMRectReadOnly; + readonly devicePixelContentBoxSize: readonly ResizeObserverSize[]; + readonly target: Element; +} + +export type ResizeObserverBoxOptions = 'border-box' | 'content-box' | 'device-pixel-content-box'; + +export interface ResizeObserverOptions { + box?: ResizeObserverBoxOptions; +} + +export interface ResizeObserver { + disconnect(): void; + observe(target: Element, options?: ResizeObserverOptions): void; + unobserve(target: Element): void; +} + +export interface ResizeObserverCallback { + (entries: ResizeObserverEntry[], observer: ResizeObserver): void; +} + +export declare let ResizeObserver: { + prototype: ResizeObserver; + new (callback: ResizeObserverCallback): ResizeObserver; +}; + +export interface StyleInformation { + stylesheet: CSSStyleSheet; + rules: Record; +} + +export type TaskCallback = (now: number) => boolean | void; + +export type TaskEntry = { c: TaskCallback; f: () => void }; diff --git a/src/runtime/internal/dev.d.ts b/src/runtime/internal/public.d.ts similarity index 62% rename from src/runtime/internal/dev.d.ts rename to src/runtime/internal/public.d.ts index 5fcef7a6e3..de7d87bb54 100644 --- a/src/runtime/internal/dev.d.ts +++ b/src/runtime/internal/public.d.ts @@ -1,19 +1,5 @@ import type { SvelteComponent } from './Component'; -export interface SvelteComponentDev< - Props extends Record = any, - Events extends Record = any, - Slots extends Record = any // eslint-disable-line @typescript-eslint/no-unused-vars -> { - $set(props?: Partial): void; - $on>( - type: K, - callback: ((e: Events[K]) => void) | null | undefined - ): () => void; - $destroy(): void; - [accessor: string]: any; -} - export interface ComponentConstructorOptions< Props extends Record = Record > { @@ -26,12 +12,37 @@ export interface ComponentConstructorOptions< $$inline?: boolean; } -// eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface SvelteComponentTyped< - Props extends Record = any, - Events extends Record = any, - Slots extends Record = any -> extends SvelteComponentDev {} +/** + * Convenience type to get the events the given component expects. Example: + * ```html + * + * + * + * ``` + */ +export type ComponentEvents = + Component extends SvelteComponentDev ? Events : never; + +/** + * Convenience type to get the props the given component expects. Example: + * ```html + * + * ``` + */ +export type ComponentProps = + Component extends SvelteComponentDev ? Props : never; /** * Convenience type to get the type of a Svelte component. Useful for example in combination with @@ -61,34 +72,87 @@ export type ComponentType - * import type { ComponentProps } from 'svelte'; - * import Component from './Component.svelte'; - * - * const props: ComponentProps = { foo: 'bar' }; // Errors if these aren't the correct props - * - * ``` - */ -export type ComponentProps = - Component extends SvelteComponentDev ? Props : never; +export interface DispatchOptions { + cancelable?: boolean; +} + +export interface EventDispatcher> { + // Implementation notes: + // - undefined extends X instead of X extends undefined makes this work better with both strict and nonstrict mode + // - [X] extends [never] is needed, X extends never would reduce the whole resulting type to never and not to one of the condition outcomes + ( + ...args: [EventMap[Type]] extends [never] + ? [type: Type, parameter?: null | undefined, options?: DispatchOptions] + : null extends EventMap[Type] + ? [type: Type, parameter?: EventMap[Type], options?: DispatchOptions] + : undefined extends EventMap[Type] + ? [type: Type, parameter?: EventMap[Type], options?: DispatchOptions] + : [type: Type, parameter: EventMap[Type], options?: DispatchOptions] + ): boolean; +} /** - * Convenience type to get the events the given component expects. Example: - * ```html - * - * - * - * ``` + * INTERNAL, DO NOT USE. Code may change at any time. */ -export type ComponentEvents = - Component extends SvelteComponentDev ? Events : never; +export interface Fragment { + key: string | null; + first: null; + /* create */ c: () => void; + /* claim */ l: (nodes: any) => void; + /* hydrate */ h: () => void; + /* mount */ m: (target: HTMLElement, anchor: any) => void; + /* update */ p: (ctx: T$$['ctx'], dirty: T$$['dirty']) => void; + /* measure */ r: () => void; + /* fix */ f: () => void; + /* animate */ a: () => void; + /* intro */ i: (local: any) => void; + /* outro */ o: (local: any) => void; + /* destroy */ d: (detaching: 0 | 1) => void; +} + +export type FragmentFactory = (ctx: any) => Fragment; + +export interface SvelteComponentDev< + Props extends Record = any, + Events extends Record = any, + Slots extends Record = any // eslint-disable-line @typescript-eslint/no-unused-vars +> { + $set(props?: Partial): void; + $on>( + type: K, + callback: ((e: Events[K]) => void) | null | undefined + ): () => void; + $destroy(): void; + [accessor: string]: any; +} + +export interface T$$ { + dirty: number[]; + ctx: any[]; + bound: any; + update: () => void; + callbacks: any; + after_update: any[]; + props: Record; + fragment: null | false | Fragment; + not_equal: any; + before_update: any[]; + context: Map; + on_mount: any[]; + on_destroy: any[]; + skip_bound: boolean; + on_disconnect: any[]; + root: Element | ShadowRoot; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface SvelteComponentTyped< + Props extends Record = any, + Events extends Record = any, + Slots extends Record = any +> extends SvelteComponentDev {} + +export interface Task { + abort(): void; + promise: Promise; +} diff --git a/src/runtime/internal/style_manager.js b/src/runtime/internal/style_manager.js index bdbd0ec43d..a98984788f 100644 --- a/src/runtime/internal/style_manager.js +++ b/src/runtime/internal/style_manager.js @@ -3,6 +3,7 @@ import { raf } from './environment.js'; // we need to store the information for multiple documents because a Svelte application could also contain iframes // https://github.com/sveltejs/svelte/issues/3624 +/** @type {Map} */ const managed_styles = new Map(); let active = 0; @@ -96,9 +97,3 @@ export function clear_rules() { managed_styles.clear(); }); } - -/** - * @typedef {Object} StyleInformation - * @property {CSSStyleSheet} stylesheet - * @property {Record} rules - */ diff --git a/src/runtime/internal/transitions.ts b/src/runtime/internal/transitions.ts index 87eb23581f..12bfc5d33c 100644 --- a/src/runtime/internal/transitions.ts +++ b/src/runtime/internal/transitions.ts @@ -5,7 +5,7 @@ import { create_rule, delete_rule } from './style_manager'; import { custom_event } from './dom'; import { add_render_callback } from './scheduler'; import { TransitionConfig } from '../transition'; -import type { Fragment } from '.'; +import type { Fragment } from './public'; let promise: Promise | null; type INTRO = 1; diff --git a/src/runtime/internal/utils.js b/src/runtime/internal/utils.js index 4e09fe43eb..10413ed6b0 100644 --- a/src/runtime/internal/utils.js +++ b/src/runtime/internal/utils.js @@ -19,8 +19,10 @@ export function assign(tar, src) { // Adapted from https://github.com/then/is-promise/blob/master/index.js // Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE -/** @param {any} value - * @returns {boolean} +/** + * @template T + * @param {any} value + * @returns {value is PromiseLike} */ export function is_promise(value) { return ( @@ -47,15 +49,17 @@ export function blank_object() { return Object.create(null); } -/** @param {Function[]} fns +/** + * @param {Function[]} fns * @returns {void} */ export function run_all(fns) { fns.forEach(run); } -/** @param {any} thing - * @returns {boolean} +/** + * @param {any} thing + * @returns {thing is Function} */ export function is_function(thing) { return typeof thing === 'function';