File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
packages/react-router-dev/typegen Expand file tree Collapse file tree 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", () => {
466466 expect ( proc . status ) . toBe ( 0 ) ;
467467 } ) ;
468468
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+
469493 test ( "dynamic import matches 'createRequestHandler' function argument type" , async ( ) => {
470494 const cwd = await createProject ( {
471495 "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> {
8989 const registerPath = Path . join ( typegenDir , "+register.ts" ) ;
9090 fs . writeFileSync ( registerPath , register ( ctx ) ) ;
9191
92- const virtualPath = Path . join ( typegenDir , "+virtual.ts" ) ;
92+ const virtualPath = Path . join ( typegenDir , "+virtual.d. ts" ) ;
9393 fs . writeFileSync ( virtualPath , virtual ) ;
9494}
9595
You can’t perform that action at this time.
0 commit comments