fix(next-utils): use natural type inference for validateMintelEnv to fix unknown type errors
Some checks failed
Monorepo Pipeline / 🚀 Release (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been cancelled
Monorepo Pipeline / 🏗️ Build (push) Has been cancelled
Monorepo Pipeline / 🧹 Lint (push) Has been cancelled
Monorepo Pipeline / 🧪 Test (push) Has been cancelled
Monorepo Pipeline / 📦 Install & Sync (push) Has been cancelled

This commit is contained in:
2026-02-11 00:17:46 +01:00
parent d8c1a38c0d
commit 4ea9cbc551
2 changed files with 4 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mintel/next-utils", "name": "@mintel/next-utils",
"version": "1.7.4", "version": "1.7.5",
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"registry": "https://npm.infra.mintel.me" "registry": "https://npm.infra.mintel.me"

View File

@@ -52,9 +52,7 @@ export const mintelEnvSchema = {
export function validateMintelEnv< export function validateMintelEnv<
T extends z.ZodRawShape = Record<string, never>, T extends z.ZodRawShape = Record<string, never>,
>( >(schemaExtension: T = {} as T) {
schemaExtension: T = {} as T,
): z.infer<z.ZodObject<typeof mintelEnvSchema & T>> {
const fullSchema = z.object(mintelEnvSchema).extend(schemaExtension); const fullSchema = z.object(mintelEnvSchema).extend(schemaExtension);
const isBuildTime = const isBuildTime =
@@ -68,7 +66,7 @@ export function validateMintelEnv<
console.warn( console.warn(
"⚠️ Some environment variables are missing during build, but skipping strict validation.", "⚠️ Some environment variables are missing during build, but skipping strict validation.",
); );
// Return process.env casted to ensure types match for the full schema // Return process.env casted to the full schema type to unblock builds
return process.env as unknown as z.infer<typeof fullSchema>; return process.env as unknown as z.infer<typeof fullSchema>;
} }
@@ -79,5 +77,5 @@ export function validateMintelEnv<
throw new Error("Invalid environment variables"); throw new Error("Invalid environment variables");
} }
return result.data as z.infer<typeof fullSchema>; return result.data;
} }