Skip to content

Commit

Permalink
add typecheck script to react-router-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Nov 15, 2024
1 parent e156dd2 commit a1e20ca
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
4 changes: 1 addition & 3 deletions packages/react-router-dev/__tests__/cli-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ describe("remix CLI", () => {
--config, -c Use specified Vite config file (string)
--no-typescript Generate plain JavaScript files
\`typegen\` Options:
--config, -c Use specified Vite config file (string)
--watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
Build your project:
Expand Down Expand Up @@ -150,8 +149,7 @@ describe("remix CLI", () => {
Generate types for route modules:
$ react-router typegen
$ react-router typegen --watch
$ react-router typegen --config vite.react-router.config.ts"
$ react-router typegen --watch"
`);
});
});
Expand Down
9 changes: 3 additions & 6 deletions packages/react-router-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,13 @@ async function createClientEntry(
return contents;
}

export async function typegen(
root: string,
flags: { watch: boolean; config?: string }
) {
export async function typegen(root: string, flags: { watch: boolean }) {
root ??= process.cwd();

if (flags.watch) {
await Typegen.watch(root, flags.config);
await Typegen.watch(root);
await new Promise(() => {}); // keep alive
return;
}
await Typegen.run(root, flags.config);
await Typegen.run(root);
}
2 changes: 0 additions & 2 deletions packages/react-router-dev/cli/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ${colors.blueBright("react-router")}
--config, -c Use specified Vite config file (string)
--no-typescript Generate plain JavaScript files
\`typegen\` Options:
--config, -c Use specified Vite config file (string)
--watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
${colors.underline("Build your project")}:
Expand Down Expand Up @@ -76,7 +75,6 @@ ${colors.blueBright("react-router")}
$ react-router typegen
$ react-router typegen --watch
$ react-router typegen --config vite.react-router.config.ts
`;

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/react-router-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"react-router": "bin.js"
},
"scripts": {
"build": "wireit"
"build": "wireit",
"typecheck": "tsc"
},
"wireit": {
"build": {
Expand Down
12 changes: 7 additions & 5 deletions packages/react-router-dev/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,

"strict": true,
"jsx": "react",

"skipLibCheck": true,
"declaration": true,
"emitDeclarationOnly": true,

"outDir": "dist",
"rootDir": ".",
"outDir": "./dist"
"noEmit": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true
}
}
2 changes: 1 addition & 1 deletion packages/react-router-dev/vite/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ServerBuild } from "react-router";
import { matchRoutes } from "react-router";
import type { ModuleNode, ViteDevServer } from "vite";

import type { ResolvedReactRouterConfig } from "./config";
import type { ResolvedReactRouterConfig } from "../config/config";
import { resolveFileUrl } from "./resolve-file-url";

type ServerRouteManifest = ServerBuild["routes"];
Expand Down

0 comments on commit a1e20ca

Please sign in to comment.