svelte2tsx 0.7.45 → 0.7.46

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 +7 -5
  2. package/index.mjs +7 -5
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -2753,7 +2753,7 @@ function attributeValueIsOfType(value, type) {
2753
2753
  * transformation this way.
2754
2754
  */
2755
2755
  function handleAwait(str, awaitBlock) {
2756
- var _a, _b;
2756
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2757
2757
  const transforms = ['{ '];
2758
2758
  if (!awaitBlock.pending.skip) {
2759
2759
  transforms.push([awaitBlock.pending.start, awaitBlock.pending.end]);
@@ -2767,13 +2767,14 @@ function handleAwait(str, awaitBlock) {
2767
2767
  const expressionEnd = withTrailingPropertyAccess(str.original, awaitBlock.expression.end);
2768
2768
  transforms.push('await (', [awaitBlock.expression.start, expressionEnd], ');');
2769
2769
  if (awaitBlock.value) {
2770
- transforms.push('{ const ', [awaitBlock.value.start, awaitBlock.value.end], ' = $$_value; ');
2770
+ const end = (_b = (_a = awaitBlock.value.typeAnnotation) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : awaitBlock.value.end;
2771
+ transforms.push('{ const ', [awaitBlock.value.start, end], ' = $$_value; ');
2771
2772
  }
2772
2773
  if (!awaitBlock.then.skip) {
2773
2774
  if (awaitBlock.pending.skip) {
2774
2775
  transforms.push([awaitBlock.then.start, awaitBlock.then.end]);
2775
2776
  }
2776
- else if ((_a = awaitBlock.then.children) === null || _a === void 0 ? void 0 : _a.length) {
2777
+ else if ((_c = awaitBlock.then.children) === null || _c === void 0 ? void 0 : _c.length) {
2777
2778
  transforms.push([
2778
2779
  awaitBlock.then.children[0].start,
2779
2780
  awaitBlock.then.children[awaitBlock.then.children.length - 1].end
@@ -2785,10 +2786,11 @@ function handleAwait(str, awaitBlock) {
2785
2786
  }
2786
2787
  if (awaitBlock.error || !awaitBlock.catch.skip) {
2787
2788
  transforms.push('} catch($$_e) { ');
2789
+ const end = (_f = (_e = (_d = awaitBlock.error) === null || _d === void 0 ? void 0 : _d.typeAnnotation) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : (_g = awaitBlock.error) === null || _g === void 0 ? void 0 : _g.end;
2788
2790
  if (awaitBlock.error) {
2789
- transforms.push('const ', [awaitBlock.error.start, awaitBlock.error.end], ' = __sveltets_2_any();');
2791
+ transforms.push('const ', [awaitBlock.error.start, end], ' = __sveltets_2_any();');
2790
2792
  }
2791
- if (!awaitBlock.catch.skip && ((_b = awaitBlock.catch.children) === null || _b === void 0 ? void 0 : _b.length)) {
2793
+ if (!awaitBlock.catch.skip && ((_h = awaitBlock.catch.children) === null || _h === void 0 ? void 0 : _h.length)) {
2792
2794
  transforms.push([
2793
2795
  awaitBlock.catch.children[0].start,
2794
2796
  awaitBlock.catch.children[awaitBlock.catch.children.length - 1].end
package/index.mjs CHANGED
@@ -2733,7 +2733,7 @@ function attributeValueIsOfType(value, type) {
2733
2733
  * transformation this way.
2734
2734
  */
2735
2735
  function handleAwait(str, awaitBlock) {
2736
- var _a, _b;
2736
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2737
2737
  const transforms = ['{ '];
2738
2738
  if (!awaitBlock.pending.skip) {
2739
2739
  transforms.push([awaitBlock.pending.start, awaitBlock.pending.end]);
@@ -2747,13 +2747,14 @@ function handleAwait(str, awaitBlock) {
2747
2747
  const expressionEnd = withTrailingPropertyAccess(str.original, awaitBlock.expression.end);
2748
2748
  transforms.push('await (', [awaitBlock.expression.start, expressionEnd], ');');
2749
2749
  if (awaitBlock.value) {
2750
- transforms.push('{ const ', [awaitBlock.value.start, awaitBlock.value.end], ' = $$_value; ');
2750
+ const end = (_b = (_a = awaitBlock.value.typeAnnotation) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : awaitBlock.value.end;
2751
+ transforms.push('{ const ', [awaitBlock.value.start, end], ' = $$_value; ');
2751
2752
  }
2752
2753
  if (!awaitBlock.then.skip) {
2753
2754
  if (awaitBlock.pending.skip) {
2754
2755
  transforms.push([awaitBlock.then.start, awaitBlock.then.end]);
2755
2756
  }
2756
- else if ((_a = awaitBlock.then.children) === null || _a === void 0 ? void 0 : _a.length) {
2757
+ else if ((_c = awaitBlock.then.children) === null || _c === void 0 ? void 0 : _c.length) {
2757
2758
  transforms.push([
2758
2759
  awaitBlock.then.children[0].start,
2759
2760
  awaitBlock.then.children[awaitBlock.then.children.length - 1].end
@@ -2765,10 +2766,11 @@ function handleAwait(str, awaitBlock) {
2765
2766
  }
2766
2767
  if (awaitBlock.error || !awaitBlock.catch.skip) {
2767
2768
  transforms.push('} catch($$_e) { ');
2769
+ const end = (_f = (_e = (_d = awaitBlock.error) === null || _d === void 0 ? void 0 : _d.typeAnnotation) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : (_g = awaitBlock.error) === null || _g === void 0 ? void 0 : _g.end;
2768
2770
  if (awaitBlock.error) {
2769
- transforms.push('const ', [awaitBlock.error.start, awaitBlock.error.end], ' = __sveltets_2_any();');
2771
+ transforms.push('const ', [awaitBlock.error.start, end], ' = __sveltets_2_any();');
2770
2772
  }
2771
- if (!awaitBlock.catch.skip && ((_b = awaitBlock.catch.children) === null || _b === void 0 ? void 0 : _b.length)) {
2773
+ if (!awaitBlock.catch.skip && ((_h = awaitBlock.catch.children) === null || _h === void 0 ? void 0 : _h.length)) {
2772
2774
  transforms.push([
2773
2775
  awaitBlock.catch.children[0].start,
2774
2776
  awaitBlock.catch.children[awaitBlock.catch.children.length - 1].end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte2tsx",
3
- "version": "0.7.45",
3
+ "version": "0.7.46",
4
4
  "description": "Convert Svelte components to TSX for type checking",
5
5
  "author": "The Svelte Community",
6
6
  "license": "MIT",
@@ -65,6 +65,6 @@
65
65
  "scripts": {
66
66
  "build": "rollup -c",
67
67
  "dev": "rollup -c -w",
68
- "test": "mocha test/test.ts"
68
+ "test": "mocha test/test.ts --no-experimental-strip-types"
69
69
  }
70
70
  }