svelte2tsx 0.6.24 → 0.6.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +10 -2
  2. package/index.mjs +10 -2
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -5650,8 +5650,9 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
5650
5650
  }
5651
5651
  }
5652
5652
  else {
5653
+ const text = ident.text;
5653
5654
  //track potential store usage to be resolved
5654
- if (ident.text.startsWith('$')) {
5655
+ if (text.startsWith('$')) {
5655
5656
  if ((!ts.isPropertyAccessExpression(parent) || parent.expression == ident) &&
5656
5657
  (!ts.isPropertyAssignment(parent) || parent.initializer == ident) &&
5657
5658
  !ts.isPropertySignature(parent) &&
@@ -5659,7 +5660,14 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
5659
5660
  !ts.isTypeReferenceNode(parent) &&
5660
5661
  !ts.isTypeAliasDeclaration(parent) &&
5661
5662
  !ts.isInterfaceDeclaration(parent)) {
5662
- pendingStoreResolutions.push({ node: ident, parent, scope });
5663
+ // Handle the const { ...props } = $props() case
5664
+ const is_rune = (text === '$props' || text === '$derived' || text === '$state') &&
5665
+ ts.isCallExpression(parent) &&
5666
+ ts.isVariableDeclaration(parent.parent) &&
5667
+ parent.parent.name.getText().includes(text.slice(1));
5668
+ if (!is_rune) {
5669
+ pendingStoreResolutions.push({ node: ident, parent, scope });
5670
+ }
5663
5671
  }
5664
5672
  }
5665
5673
  }
package/index.mjs CHANGED
@@ -5630,8 +5630,9 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
5630
5630
  }
5631
5631
  }
5632
5632
  else {
5633
+ const text = ident.text;
5633
5634
  //track potential store usage to be resolved
5634
- if (ident.text.startsWith('$')) {
5635
+ if (text.startsWith('$')) {
5635
5636
  if ((!ts.isPropertyAccessExpression(parent) || parent.expression == ident) &&
5636
5637
  (!ts.isPropertyAssignment(parent) || parent.initializer == ident) &&
5637
5638
  !ts.isPropertySignature(parent) &&
@@ -5639,7 +5640,14 @@ function processInstanceScriptContent(str, script, events, implicitStoreValues,
5639
5640
  !ts.isTypeReferenceNode(parent) &&
5640
5641
  !ts.isTypeAliasDeclaration(parent) &&
5641
5642
  !ts.isInterfaceDeclaration(parent)) {
5642
- pendingStoreResolutions.push({ node: ident, parent, scope });
5643
+ // Handle the const { ...props } = $props() case
5644
+ const is_rune = (text === '$props' || text === '$derived' || text === '$state') &&
5645
+ ts.isCallExpression(parent) &&
5646
+ ts.isVariableDeclaration(parent.parent) &&
5647
+ parent.parent.name.getText().includes(text.slice(1));
5648
+ if (!is_rune) {
5649
+ pendingStoreResolutions.push({ node: ident, parent, scope });
5650
+ }
5643
5651
  }
5644
5652
  }
5645
5653
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte2tsx",
3
- "version": "0.6.24",
3
+ "version": "0.6.25",
4
4
  "description": "Convert Svelte components to TSX for type checking",
5
5
  "author": "David Pershouse",
6
6
  "license": "MIT",