Skip to content

Commit a0549b4

Browse files
committed
more
1 parent 8ceb083 commit a0549b4

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

packages/svelte/src/index-server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
/** @import { Component } from '#server' */
12
import { current_component } from './internal/server/context.js';
23
import { noop } from './internal/shared/utils.js';
34
import * as e from './internal/server/errors.js';
45

56
/** @param {() => void} fn */
67
export function onDestroy(fn) {
7-
var context = /** @type {import('#server').Component} */ (current_component);
8+
var context = /** @type {Component} */ (current_component);
89
(context.d ??= []).push(fn);
910
}
1011

packages/svelte/src/internal/client/proxy.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @import { ProxyMetadata, ProxyStateObject, Source } from '#client' */
12
import { DEV } from 'esm-env';
23
import { get, current_component_context, untrack, current_effect } from './runtime.js';
34
import {
@@ -18,9 +19,9 @@ import * as e from './errors.js';
1819
/**
1920
* @template T
2021
* @param {T} value
21-
* @param {import('#client').ProxyMetadata | null} [parent]
22-
* @param {import('#client').Source<T>} [prev] dev mode only
23-
* @returns {import('#client').ProxyStateObject<T> | T}
22+
* @param {ProxyMetadata | null} [parent]
23+
* @param {Source<T>} [prev] dev mode only
24+
* @returns {ProxyStateObject<T> | T}
2425
*/
2526
export function proxy(value, parent = null, prev) {
2627
if (
@@ -31,7 +32,7 @@ export function proxy(value, parent = null, prev) {
3132
) {
3233
// If we have an existing proxy, return it...
3334
if (STATE_SYMBOL in value) {
34-
const metadata = /** @type {import('#client').ProxyMetadata<T>} */ (value[STATE_SYMBOL]);
35+
const metadata = /** @type {ProxyMetadata<T>} */ (value[STATE_SYMBOL]);
3536

3637
// ...unless the proxy belonged to a different object, because
3738
// someone copied the state symbol using `Reflect.ownKeys(...)`
@@ -53,7 +54,7 @@ export function proxy(value, parent = null, prev) {
5354
const proxy = new Proxy(value, state_proxy_handler);
5455

5556
define_property(value, STATE_SYMBOL, {
56-
value: /** @type {import('#client').ProxyMetadata} */ ({
57+
value: /** @type {ProxyMetadata} */ ({
5758
s: new Map(),
5859
v: source(0),
5960
a: is_array(value),
@@ -94,18 +95,18 @@ export function proxy(value, parent = null, prev) {
9495
}
9596

9697
/**
97-
* @param {import('#client').Source<number>} signal
98+
* @param {Source<number>} signal
9899
* @param {1 | -1} [d]
99100
*/
100101
function update_version(signal, d = 1) {
101102
set(signal, signal.v + d);
102103
}
103104

104-
/** @type {ProxyHandler<import('#client').ProxyStateObject<any>>} */
105+
/** @type {ProxyHandler<ProxyStateObject<any>>} */
105106
const state_proxy_handler = {
106107
defineProperty(target, prop, descriptor) {
107108
if (descriptor.value) {
108-
/** @type {import('#client').ProxyMetadata} */
109+
/** @type {ProxyMetadata} */
109110
const metadata = target[STATE_SYMBOL];
110111

111112
const s = metadata.s.get(prop);
@@ -116,7 +117,7 @@ const state_proxy_handler = {
116117
},
117118

118119
deleteProperty(target, prop) {
119-
/** @type {import('#client').ProxyMetadata} */
120+
/** @type {ProxyMetadata} */
120121
const metadata = target[STATE_SYMBOL];
121122
const s = metadata.s.get(prop);
122123
const is_array = metadata.a;
@@ -149,7 +150,7 @@ const state_proxy_handler = {
149150
return Reflect.get(target, STATE_SYMBOL);
150151
}
151152

152-
/** @type {import('#client').ProxyMetadata} */
153+
/** @type {ProxyMetadata} */
153154
const metadata = target[STATE_SYMBOL];
154155
let s = metadata.s.get(prop);
155156

@@ -170,7 +171,7 @@ const state_proxy_handler = {
170171
getOwnPropertyDescriptor(target, prop) {
171172
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
172173
if (descriptor && 'value' in descriptor) {
173-
/** @type {import('#client').ProxyMetadata} */
174+
/** @type {ProxyMetadata} */
174175
const metadata = target[STATE_SYMBOL];
175176
const s = metadata.s.get(prop);
176177

@@ -186,7 +187,7 @@ const state_proxy_handler = {
186187
if (prop === STATE_SYMBOL) {
187188
return true;
188189
}
189-
/** @type {import('#client').ProxyMetadata} */
190+
/** @type {ProxyMetadata} */
190191
const metadata = target[STATE_SYMBOL];
191192
const has = Reflect.has(target, prop);
192193

@@ -208,7 +209,7 @@ const state_proxy_handler = {
208209
},
209210

210211
set(target, prop, value, receiver) {
211-
/** @type {import('#client').ProxyMetadata} */
212+
/** @type {ProxyMetadata} */
212213
const metadata = target[STATE_SYMBOL];
213214
let s = metadata.s.get(prop);
214215
// If we haven't yet created a source for this property, we need to ensure
@@ -227,7 +228,7 @@ const state_proxy_handler = {
227228
const not_has = !(prop in target);
228229

229230
if (DEV) {
230-
/** @type {import('#client').ProxyMetadata | undefined} */
231+
/** @type {ProxyMetadata | undefined} */
231232
const prop_metadata = value?.[STATE_SYMBOL];
232233
if (prop_metadata && prop_metadata?.parent !== metadata) {
233234
widen_ownership(metadata, prop_metadata);
@@ -271,7 +272,7 @@ const state_proxy_handler = {
271272
},
272273

273274
ownKeys(target) {
274-
/** @type {import('#client').ProxyMetadata} */
275+
/** @type {ProxyMetadata} */
275276
const metadata = target[STATE_SYMBOL];
276277

277278
get(metadata.v);

packages/svelte/src/internal/client/render.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** @import { ComponentContext, Effect, EffectNodes, TemplateNode } from '#client' */
2+
/** @import { Component, ComponentType, SvelteComponent } from '../../index.js' */
13
import { DEV } from 'esm-env';
24
import { clear_text_content, empty, init_operations } from './dom/operations.js';
35
import {
@@ -59,7 +61,7 @@ export function set_text(text, value) {
5961
*
6062
* @template {Record<string, any>} Props
6163
* @template {Record<string, any>} Exports
62-
* @param {import('../../index.js').ComponentType<import('../../index.js').SvelteComponent<Props>> | import('../../index.js').Component<Props, Exports, any>} component
64+
* @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
6365
* @param {{} extends Props ? {
6466
* target: Document | Element | ShadowRoot;
6567
* anchor?: Node;
@@ -87,7 +89,7 @@ export function mount(component, options) {
8789
*
8890
* @template {Record<string, any>} Props
8991
* @template {Record<string, any>} Exports
90-
* @param {import('../../index.js').ComponentType<import('../../index.js').SvelteComponent<Props>> | import('../../index.js').Component<Props, Exports, any>} component
92+
* @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
9193
* @param {{} extends Props ? {
9294
* target: Document | Element | ShadowRoot;
9395
* props?: Props;
@@ -112,12 +114,12 @@ export function hydrate(component, options) {
112114
const previous_hydrate_node = hydrate_node;
113115

114116
try {
115-
var anchor = /** @type {import('#client').TemplateNode} */ (target.firstChild);
117+
var anchor = /** @type {TemplateNode} */ (target.firstChild);
116118
while (
117119
anchor &&
118120
(anchor.nodeType !== 8 || /** @type {Comment} */ (anchor).data !== HYDRATION_START)
119121
) {
120-
anchor = /** @type {import('#client').TemplateNode} */ (anchor.nextSibling);
122+
anchor = /** @type {TemplateNode} */ (anchor.nextSibling);
121123
}
122124

123125
if (!anchor) {
@@ -171,7 +173,7 @@ const document_listeners = new Map();
171173

172174
/**
173175
* @template {Record<string, any>} Exports
174-
* @param {import('../../index.js').ComponentType<import('../../index.js').SvelteComponent<any>> | import('../../index.js').Component<any>} Component
176+
* @param {ComponentType<SvelteComponent<any>> | Component<any>} Component
175177
* @param {{
176178
* target: Document | Element | ShadowRoot;
177179
* anchor: Node;
@@ -226,7 +228,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
226228
branch(() => {
227229
if (context) {
228230
push({});
229-
var ctx = /** @type {import('#client').ComponentContext} */ (current_component_context);
231+
var ctx = /** @type {ComponentContext} */ (current_component_context);
230232
ctx.c = context;
231233
}
232234

@@ -236,7 +238,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
236238
}
237239

238240
if (hydrating) {
239-
assign_nodes(/** @type {import('#client').TemplateNode} */ (anchor), null);
241+
assign_nodes(/** @type {TemplateNode} */ (anchor), null);
240242
}
241243

242244
should_intro = intro;
@@ -245,9 +247,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
245247
should_intro = true;
246248

247249
if (hydrating) {
248-
/** @type {import('#client').Effect & { nodes: import('#client').EffectNodes }} */ (
249-
current_effect
250-
).nodes.end = hydrate_node;
250+
/** @type {Effect & { nodes: EffectNodes }} */ (current_effect).nodes.end = hydrate_node;
251251
}
252252

253253
if (context) {

0 commit comments

Comments
 (0)