From 784ac77e08f57a77c92f76d4170598bcfcf4e651 Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Sun, 9 Jun 2024 10:48:36 -0400 Subject: [PATCH] fix: generated Env declaration not extending HonoEnv --- src/scripts/generateEnv.ts | 7 ++++--- src/types/env.d.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/scripts/generateEnv.ts b/src/scripts/generateEnv.ts index 135f707..3d46ae8 100644 --- a/src/scripts/generateEnv.ts +++ b/src/scripts/generateEnv.ts @@ -22,13 +22,14 @@ const secretNames = await logStep( const project = new Project({}); -const envFile = project.addSourceFileAtPath("src/types/env.d.ts"); -envFile.insertImportDeclaration(2, { +const envSourceFile = project.addSourceFileAtPath("src/types/env.d.ts"); +envSourceFile.insertImportDeclaration(2, { isTypeOnly: true, moduleSpecifier: "hono", namedImports: ["Env as HonoEnv"], }); -envFile.getInterfaceOrThrow("Env").addProperties( +envSourceFile.getInterfaceOrThrow("Env").addExtends("HonoEnv"); +envSourceFile.getInterfaceOrThrow("Env").addProperties( secretNames.map((name) => ({ name, type: `string`, diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 08a9858..29a312b 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -1,10 +1,11 @@ -// Generated by Wrangler on Tue Jun 04 2024 08:51:21 GMT-0400 (Eastern Daylight Time) +// Generated by Wrangler on Sun Jun 09 2024 10:47:45 GMT-0400 (Eastern Daylight Time) // by running `wrangler types src/types/env.d.ts` import type { Env as HonoEnv } from "hono"; -interface Env { +interface Env extends HonoEnv { TURSO_URL: "libsql://humble-argent-silverandroid.turso.io"; QSTASH_URL: "https://qstash.upstash.io/v2/publish"; - ENABLE_ANIFY: boolean; + ENABLE_ANIFY: false; + ADMIN_SDK_JSON: string; TURSO_AUTH_TOKEN: string; }