diff --git a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
index 326077585..b248e2045 100644
--- a/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
+++ b/packages/svelte2tsx/src/svelte2tsx/processInstanceScriptContent.ts
@@ -119,8 +119,9 @@ export function processInstanceScriptContent(
}
}
} else {
+ const text = ident.text;
//track potential store usage to be resolved
- if (ident.text.startsWith('$')) {
+ if (text.startsWith('$')) {
if (
(!ts.isPropertyAccessExpression(parent) || parent.expression == ident) &&
(!ts.isPropertyAssignment(parent) || parent.initializer == ident) &&
@@ -130,7 +131,15 @@ export function processInstanceScriptContent(
!ts.isTypeAliasDeclaration(parent) &&
!ts.isInterfaceDeclaration(parent)
) {
- pendingStoreResolutions.push({ node: ident, parent, scope });
+ // Handle the const { ...props } = $props() case
+ const is_rune =
+ (text === '$props' || text === '$derived' || text === '$state') &&
+ ts.isCallExpression(parent) &&
+ ts.isVariableDeclaration(parent.parent) &&
+ parent.parent.name.getText().includes(text.slice(1));
+ if (!is_rune) {
+ pendingStoreResolutions.push({ node: ident, parent, scope });
+ }
}
}
}
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/runes-looking-like-stores/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/runes-looking-like-stores/expectedv2.ts
new file mode 100644
index 000000000..2b5181184
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/runes-looking-like-stores/expectedv2.ts
@@ -0,0 +1,14 @@
+///
+;function render() {
+
+ let { props } = $props();
+ let state = $state(0);
+ let derived = $derived(state * 2);
+;
+async () => {
+
+state; derived;};
+return { props: /** @type {Record} */ ({}), slots: {}, events: {} }}
+
+export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event(render()))) {
+}
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/runes-looking-like-stores/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/runes-looking-like-stores/input.svelte
new file mode 100644
index 000000000..f52eae863
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/runes-looking-like-stores/input.svelte
@@ -0,0 +1,7 @@
+
+
+{state} {derived}
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/stores-looking-like-runes/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/stores-looking-like-runes/expectedv2.ts
new file mode 100644
index 000000000..847615f9a
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/stores-looking-like-runes/expectedv2.ts
@@ -0,0 +1,17 @@
+///
+;function render() {
+
+ const props = null/*Ωignore_startΩ*/;let $props = __sveltets_2_store_get(props);/*Ωignore_endΩ*/;
+ $props;
+ const state = null/*Ωignore_startΩ*/;let $state = __sveltets_2_store_get(state);/*Ωignore_endΩ*/;
+ $state;
+ const derived = null/*Ωignore_startΩ*/;let $derived = __sveltets_2_store_get(derived);/*Ωignore_endΩ*/;
+ $derived;
+;
+async () => {
+
+state; derived;};
+return { props: /** @type {Record} */ ({}), slots: {}, events: {} }}
+
+export default class Input__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(__sveltets_2_with_any_event(render()))) {
+}
\ No newline at end of file
diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/stores-looking-like-runes/input.svelte b/packages/svelte2tsx/test/svelte2tsx/samples/stores-looking-like-runes/input.svelte
new file mode 100644
index 000000000..f38b77854
--- /dev/null
+++ b/packages/svelte2tsx/test/svelte2tsx/samples/stores-looking-like-runes/input.svelte
@@ -0,0 +1,10 @@
+
+
+{state} {derived}