Skip to content

Commit 8d2a7d0

Browse files
committed
use SignalDebug
1 parent b025d48 commit 8d2a7d0

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

packages/svelte/src/internal/client/dev/ownership.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ export function mark_module_end() {
8383
let new_owner = null;
8484

8585
/**
86-
* @param {import('../types.js').Signal} signal
86+
* @param {import('../types.js').SignalDebug} signal
8787
*/
8888
export function set_owners(signal) {
89-
// @ts-expect-error
9089
if (current_owners && signal.owners) {
9190
for (const owner of current_owners) {
92-
// @ts-expect-error
9391
signal.owners.add(owner);
9492
}
9593
}
@@ -109,31 +107,27 @@ export function add_owner(object, owner) {
109107
}
110108

111109
/**
112-
* @param {import('../types.js').Signal} signal
110+
* @param {import('../types.js').SignalDebug} signal
113111
*/
114112
export function add_owner_to_signal(signal) {
115113
if (
116114
new_owner &&
117115
// @ts-expect-error
118116
signal.owners?.has(current_component_context.function)
119117
) {
120-
// @ts-expect-error
121118
signal.owners.add(new_owner);
122119
}
123120
}
124121

125122
/**
126-
* @param {import('../types.js').Signal} signal
123+
* @param {import('../types.js').SignalDebug} signal
127124
*/
128125
export function check_ownership(signal) {
129-
// @ts-expect-error
130126
if (!signal.owners) return;
131127

132128
const component = get_component();
133129

134-
// @ts-expect-error
135130
if (component && signal.owners.size > 0 && !signal.owners.has(component)) {
136-
// @ts-expect-error
137131
let owner = [...signal.owners][0];
138132

139133
let message =

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,13 @@ export function unsubscribe_on_destroy(stores) {
951951
*/
952952
export function get(signal) {
953953
if (DEV) {
954-
add_owner_to_signal(signal);
954+
const debuggable = /** @type {import('./types.js').SignalDebug} */ (signal);
955+
956+
add_owner_to_signal(debuggable);
955957

956958
// @ts-expect-error
957959
if (signal.inspect && inspect_fn) {
958-
/** @type {import('./types.js').SignalDebug} */ (signal).inspect.add(inspect_fn);
960+
debuggable.inspect.add(inspect_fn);
959961
// @ts-expect-error
960962
inspect_captured_signals.push(signal);
961963
}
@@ -1025,7 +1027,7 @@ export function get(signal) {
10251027
*/
10261028
export function set(signal, value) {
10271029
if (DEV) {
1028-
check_ownership(signal);
1030+
check_ownership(/** @type {import('./types.js').SignalDebug} */ (signal));
10291031
}
10301032

10311033
set_signal_value(signal, value);
@@ -1344,7 +1346,7 @@ export function source(initial_value) {
13441346
*/
13451347
function bind_signal_to_component_context(signal) {
13461348
if (DEV) {
1347-
set_owners(signal);
1349+
set_owners(/** @type {import('./types.js').SignalDebug} */ (signal));
13481350
}
13491351

13501352
if (current_component_context === null || !current_component_context.r) return;

0 commit comments

Comments
 (0)