fix: generated Env declaration not extending HonoEnv

This commit is contained in:
2024-06-09 10:48:36 -04:00
parent 3da4325be1
commit 784ac77e08
2 changed files with 8 additions and 6 deletions

View File

@@ -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`,

7
src/types/env.d.ts vendored
View File

@@ -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;
}