@@ -390,18 +390,13 @@ function process_node(ts, node, outdir, params, groups) {
390
390
const types = [ ] ;
391
391
for ( const method of [ 'POST' , 'PUT' , 'PATCH' ] ) {
392
392
if ( proxy . exports . includes ( method ) ) {
393
- if ( proxy . modified ) {
394
- types . push ( `Kit.AwaitedErrors<typeof import('./proxy${ basename } ').${ method } >` ) ;
395
- } else {
396
- // If the file wasn't tweaked, we can use the return type of the original file.
397
- // The advantage is that type updates are reflected without saving.
398
- types . push (
399
- `Kit.AwaitedErrors<typeof import("${ path_to_original (
400
- outdir ,
401
- node . server
402
- ) } ").${ method } >`
403
- ) ;
404
- }
393
+ // If the file wasn't tweaked, we can use the return type of the original file.
394
+ // The advantage is that type updates are reflected without saving.
395
+ const from = proxy . modified
396
+ ? `./proxy${ replace_ext_with_js ( basename ) } `
397
+ : path_to_original ( outdir , node . server ) ;
398
+
399
+ types . push ( `Kit.AwaitedErrors<typeof import('${ from } ').${ method } >` ) ;
405
400
}
406
401
}
407
402
errors = types . length ? types . join ( ' | ' ) : 'null' ;
@@ -494,18 +489,17 @@ function process_node(ts, node, outdir, params, groups) {
494
489
* @param {string } file_path
495
490
*/
496
491
function path_to_original ( outdir , file_path ) {
492
+ return posixify ( path . relative ( outdir , path . join ( cwd , replace_ext_with_js ( file_path ) ) ) ) ;
493
+ }
494
+
495
+ /**
496
+ * @param {string } file_path
497
+ */
498
+ function replace_ext_with_js ( file_path ) {
499
+ // Another extension than `.js` (or nothing, but that fails with node16 moduleResolution)
500
+ // will result in TS failing to lookup the file
497
501
const ext = path . extname ( file_path ) ;
498
- return posixify (
499
- path . relative (
500
- outdir ,
501
- path . join (
502
- cwd ,
503
- // Another extension than `.js` (or nothing, but that fails with node16 moduleResolution)
504
- // will result in TS failing to lookup the file
505
- file_path . slice ( 0 , - ext . length ) + '.js'
506
- )
507
- )
508
- ) ;
502
+ return file_path . slice ( 0 , - ext . length ) + '.js' ;
509
503
}
510
504
511
505
/**
@@ -722,10 +716,6 @@ export function find_nearest_layout(routes_dir, nodes, start_idx) {
722
716
}
723
717
724
718
// matching parent layout found
725
- // let import_path = posixify(path.relative(path.dirname(start_file), common_path + '/$types.js'));
726
- // if (!import_path.startsWith('.')) {
727
- // import_path = './' + import_path;
728
- // }
729
719
let folder_depth_diff =
730
720
posixify ( path . relative ( path . dirname ( start_file ) , common_path + '/$types.js' ) ) . split ( '/' )
731
721
. length - 1 ;
0 commit comments