@@ -246,12 +246,9 @@ function makeWrappedRootLoader() {
246246 } ;
247247}
248248
249- function wrapRequestHandler (
249+ function wrapRequestHandler < T extends ServerBuild | ( ( ) => ServerBuild | Promise < ServerBuild > ) > (
250250 origRequestHandler : RequestHandler ,
251- build :
252- | ServerBuild
253- | { build : ServerBuild }
254- | ( ( ) => ServerBuild | { build : ServerBuild } | Promise < ServerBuild | { build : ServerBuild } > ) ,
251+ build : T ,
255252 options ?: {
256253 instrumentTracing ?: boolean ;
257254 } ,
@@ -278,7 +275,7 @@ function wrapRequestHandler(
278275
279276 // check if the build is nested under `build` key
280277 if ( 'build' in resolvedBuild ) {
281- resolvedRoutes = createRoutes ( resolvedBuild . build . routes ) ;
278+ resolvedRoutes = createRoutes ( ( resolvedBuild . build as ServerBuild ) . routes ) ;
282279 } else {
283280 resolvedRoutes = createRoutes ( resolvedBuild . routes ) ;
284281 }
@@ -407,12 +404,12 @@ function instrumentBuildCallback(
407404/**
408405 * Instruments `remix` ServerBuild for performance tracing and error tracking.
409406 */
410- export function instrumentBuild (
411- build : ServerBuild | ( ( ) => ServerBuild | Promise < ServerBuild > ) ,
407+ export function instrumentBuild < T extends ServerBuild | ( ( ) => ServerBuild | Promise < ServerBuild > ) > (
408+ build : T ,
412409 options ?: {
413410 instrumentTracing ?: boolean ;
414411 } ,
415- ) : ServerBuild | ( ( ) => ServerBuild | Promise < ServerBuild > ) {
412+ ) : T {
416413 if ( typeof build === 'function' ) {
417414 return function ( ) {
418415 const resolvedBuild = build ( ) ;
@@ -424,9 +421,9 @@ export function instrumentBuild(
424421 } else {
425422 return instrumentBuildCallback ( resolvedBuild , options ) ;
426423 }
427- } ;
424+ } as T ;
428425 } else {
429- return instrumentBuildCallback ( build , options ) ;
426+ return instrumentBuildCallback ( build , options ) as T ;
430427 }
431428}
432429
0 commit comments