Skip to content

Commit 0792bfd

Browse files
dmealingclaude
andcommitted
fix(cli): type the quickstart smoke test's generated-module import
The generated routes module has no compile-time type (it is emitted during the test), and the cast used `Parameters<ReturnType<typeof Fastify>["register"]>[0]`, which tsc could not match to a register overload; the PATCH response body was also read as `unknown`. Use Fastify's own `FastifyPluginAsync` and narrow the response body. The fix was written before the previous push but never landed: the amend that should have carried it was blocked by the public-repo commit guard (an unrelated scratch file had been swept into the index), the error was swallowed, and the pre-push typecheck gate passed because it checks the WORKING TREE, not HEAD — so the type-broken version is what got pushed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 4735bbd commit 0792bfd

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

server/typescript/packages/cli/test/integration/quickstart-smoke.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { describe, test, expect } from "bun:test";
1818
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
1919
import { join, resolve } from "node:path";
20+
import type { FastifyPluginAsync } from "fastify";
2021
import { run } from "../../src/index.js";
2122

2223
// Temp roots live inside the monorepo so the generated code and the config can
@@ -109,8 +110,10 @@ describe("quickstart smoke — the documented TS path, gen -> migrate -> boot ->
109110

110111
// 3. boot the GENERATED routes plugin on Fastify, as the doc shows
111112
const { default: Fastify } = await import("fastify");
113+
// The routes module is generated at runtime, so its type isn't knowable at
114+
// compile time — register through Fastify's own plugin type.
112115
const { authorRoutes } = (await import(join(outDir, "Author.routes.ts"))) as {
113-
authorRoutes: Parameters<ReturnType<typeof Fastify>["register"]>[0];
116+
authorRoutes: FastifyPluginAsync;
114117
};
115118
const app = Fastify();
116119
await app.register(authorRoutes);
@@ -159,7 +162,7 @@ describe("quickstart smoke — the documented TS path, gen -> migrate -> boot ->
159162
body: JSON.stringify({ bio: "First programmer" }),
160163
});
161164
expect(patched.status).toBe(200);
162-
expect((await patched.json()).bio).toBe("First programmer");
165+
expect(((await patched.json()) as { bio: string }).bio).toBe("First programmer");
163166

164167
// 8. delete -> 204
165168
const deleted = await fetch(`${base}/authors/${row.id}`, { method: "DELETE" });

0 commit comments

Comments
 (0)