File tree 3 files changed +30
-1
lines changed
packages/react-router-dev/typegen
3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @react-router/dev " : patch
3
+ ---
4
+
5
+ Fix typegen for virtual modules when ` moduleDetection ` is set to ` force `
Original file line number Diff line number Diff line change @@ -466,6 +466,30 @@ test.describe("typegen", () => {
466
466
expect ( proc . status ) . toBe ( 0 ) ;
467
467
} ) ;
468
468
469
+ test ( "works with tsconfig 'moduleDetection' set to 'force'" , async ( ) => {
470
+ const cwd = await createProject ( {
471
+ "vite.config.ts" : viteConfig ,
472
+ "app/routes.ts" : tsx `
473
+ import { type RouteConfig } from "@react-router/dev/routes";
474
+ export default [] satisfies RouteConfig;
475
+ ` ,
476
+ "app/handler.ts" : tsx `
477
+ import { createRequestHandler } from "react-router";
478
+ import * as serverBuild from "virtual:react-router/server-build";
479
+ export default createRequestHandler(serverBuild);
480
+ ` ,
481
+ } ) ;
482
+
483
+ const tsconfig = await fse . readJson ( path . join ( cwd , "tsconfig.json" ) ) ;
484
+ tsconfig . compilerOptions . moduleDetection = "force" ;
485
+ await fse . writeJson ( path . join ( cwd , "tsconfig.json" ) , tsconfig ) ;
486
+
487
+ const proc = typecheck ( cwd ) ;
488
+ expect ( proc . stdout . toString ( ) ) . toBe ( "" ) ;
489
+ expect ( proc . stderr . toString ( ) ) . toBe ( "" ) ;
490
+ expect ( proc . status ) . toBe ( 0 ) ;
491
+ } ) ;
492
+
469
493
test ( "dynamic import matches 'createRequestHandler' function argument type" , async ( ) => {
470
494
const cwd = await createProject ( {
471
495
"vite.config.ts" : viteConfig ,
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ async function writeAll(ctx: Context): Promise<void> {
89
89
const registerPath = Path . join ( typegenDir , "+register.ts" ) ;
90
90
fs . writeFileSync ( registerPath , register ( ctx ) ) ;
91
91
92
- const virtualPath = Path . join ( typegenDir , "+virtual.ts" ) ;
92
+ const virtualPath = Path . join ( typegenDir , "+virtual.d. ts" ) ;
93
93
fs . writeFileSync ( virtualPath , virtual ) ;
94
94
}
95
95
You can’t perform that action at this time.
0 commit comments