svelte2tsx 0.6.11 → 0.6.13

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 +14 -0
  2. package/index.mjs +14 -0
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -3697,6 +3697,20 @@ function upserKitRouteFile(ts, basename, getSource, surround) {
3697
3697
  const inserted = surround(`: import('./$types.js').${basename.includes('layout') ? 'Layout' : 'Page'}${basename.includes('server') ? 'Server' : ''}LoadEvent`);
3698
3698
  insert(pos, inserted);
3699
3699
  }
3700
+ // add type to entries function if not explicitly typed
3701
+ const entries = exports.get('entries');
3702
+ if ((entries === null || entries === void 0 ? void 0 : entries.type) === 'function' &&
3703
+ entries.node.parameters.length === 0 &&
3704
+ !entries.hasTypeDefinition &&
3705
+ !basename.includes('layout')) {
3706
+ if (!entries.node.type && entries.node.body) {
3707
+ const returnPos = ts.isArrowFunction(entries.node)
3708
+ ? entries.node.equalsGreaterThanToken.getStart()
3709
+ : entries.node.body.getStart();
3710
+ const returnInsertion = surround(`: ReturnType<import('./$types.js').EntryGenerator> `);
3711
+ insert(returnPos, returnInsertion);
3712
+ }
3713
+ }
3700
3714
  // add type to actions variable if not explicitly typed
3701
3715
  const actions = exports.get('actions');
3702
3716
  if ((actions === null || actions === void 0 ? void 0 : actions.type) === 'var' && !actions.hasTypeDefinition && actions.node.initializer) {
package/index.mjs CHANGED
@@ -3677,6 +3677,20 @@ function upserKitRouteFile(ts, basename, getSource, surround) {
3677
3677
  const inserted = surround(`: import('./$types.js').${basename.includes('layout') ? 'Layout' : 'Page'}${basename.includes('server') ? 'Server' : ''}LoadEvent`);
3678
3678
  insert(pos, inserted);
3679
3679
  }
3680
+ // add type to entries function if not explicitly typed
3681
+ const entries = exports.get('entries');
3682
+ if ((entries === null || entries === void 0 ? void 0 : entries.type) === 'function' &&
3683
+ entries.node.parameters.length === 0 &&
3684
+ !entries.hasTypeDefinition &&
3685
+ !basename.includes('layout')) {
3686
+ if (!entries.node.type && entries.node.body) {
3687
+ const returnPos = ts.isArrowFunction(entries.node)
3688
+ ? entries.node.equalsGreaterThanToken.getStart()
3689
+ : entries.node.body.getStart();
3690
+ const returnInsertion = surround(`: ReturnType<import('./$types.js').EntryGenerator> `);
3691
+ insert(returnPos, returnInsertion);
3692
+ }
3693
+ }
3680
3694
  // add type to actions variable if not explicitly typed
3681
3695
  const actions = exports.get('actions');
3682
3696
  if ((actions === null || actions === void 0 ? void 0 : actions.type) === 'var' && !actions.hasTypeDefinition && actions.node.initializer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte2tsx",
3
- "version": "0.6.11",
3
+ "version": "0.6.13",
4
4
  "description": "Convert Svelte components to TSX for type checking",
5
5
  "author": "David Pershouse",
6
6
  "license": "MIT",