File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
packages/svelte2tsx/src/helpers Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,23 @@ function upserKitRouteFile(
171171 insert ( pos , inserted ) ;
172172 }
173173
174+ // add type to entries function if not explicitly typed
175+ const entries = exports . get ( 'entries' ) ;
176+ if (
177+ entries ?. type === 'function' &&
178+ entries . node . parameters . length === 0 &&
179+ ! entries . hasTypeDefinition &&
180+ ! basename . includes ( 'layout' )
181+ ) {
182+ if ( ! entries . node . type && entries . node . body ) {
183+ const returnPos = ts . isArrowFunction ( entries . node )
184+ ? entries . node . equalsGreaterThanToken . getStart ( )
185+ : entries . node . body . getStart ( ) ;
186+ const returnInsertion = surround ( `: ReturnType<import('./$types.js').EntryGenerator> ` ) ;
187+ insert ( returnPos , returnInsertion ) ;
188+ }
189+ }
190+
174191 // add type to actions variable if not explicitly typed
175192 const actions = exports . get ( 'actions' ) ;
176193 if ( actions ?. type === 'var' && ! actions . hasTypeDefinition && actions . node . initializer ) {
You can’t perform that action at this time.
0 commit comments