chore: add typecheck script and fix pre-existing TypeScript errors

- Add `typecheck` script (`tsc --noEmit`) to package.json
- Remove conflicting `declare global` from test/setup.ts (superseded
  by @cloudflare/workers-types); use `globalThis as any` for test globals
  and declare minimal `require` locally to avoid pulling in @types/node
- Cast `createMockEnv()` and `deleteRes.json()` results in admin.test.ts
  to silence strict `unknown` / MockKV-vs-KVNamespace errors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Julien Herr
2026-05-20 22:54:32 +02:00
parent 3ed9d2ee22
commit 29446a2aac
3 changed files with 32 additions and 38 deletions
+6 -6
View File
@@ -11,10 +11,10 @@ describe("Admin Routes", () => {
let loginAndGetCookie: () => Promise<string>;
beforeEach(() => {
mockEnv = createMockEnv();
mockEnv = createMockEnv() as unknown as Env;
testApp = new Hono();
testApp.route("/admin", app);
request = (path, init = {}) => testApp.request(path, init, mockEnv);
request = (path, init = {}) => Promise.resolve(testApp.request(path, init, mockEnv));
loginAndGetCookie = async () => {
const formData = new FormData();
formData.append("password", "test-password");
@@ -161,8 +161,8 @@ describe("Admin Routes", () => {
"json",
);
expect(feedConfig).toBeTruthy();
expect(feedConfig.title).toBe("Test Feed");
expect(feedConfig.description).toBe("Test Description");
expect((feedConfig as any).title).toBe("Test Feed");
expect((feedConfig as any).description).toBe("Test Description");
});
it("should reject feed creation with missing title", async () => {
@@ -297,7 +297,7 @@ describe("Admin Routes", () => {
);
expect(deleteRes.status).toBe(200);
const payload = await deleteRes.json();
const payload = (await deleteRes.json()) as any;
expect(payload.ok).toBe(true);
expect(payload.feedId).toBe(feedId);
});
@@ -419,7 +419,7 @@ describe("Admin Routes", () => {
);
expect(deleteRes.status).toBe(200);
const payload = await deleteRes.json();
const payload = (await deleteRes.json()) as any;
expect(payload.ok).toBe(true);
expect(payload.emailKey).toBe(emailKey);