fix(next-utils): restore optional argument with robust types to satisfy linter
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 / 🧪 Quality Assurance (push) Has been cancelled

This commit is contained in:
2026-02-11 00:02:53 +01:00
parent 6bc49d1c52
commit 149123ef90
2 changed files with 10 additions and 5 deletions

View File

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

View File

@@ -50,7 +50,12 @@ export const mintelEnvSchema = {
INTERNAL_DIRECTUS_URL: z.string().url().optional(),
};
export function validateMintelEnv<T extends z.ZodRawShape>(schemaExtension: T) {
export type MintelEnv<T extends z.ZodRawShape = Record<string, never>> =
z.infer<z.ZodObject<typeof mintelEnvSchema & T>>;
export function validateMintelEnv<
T extends z.ZodRawShape = Record<string, never>,
>(schemaExtension: T = {} as T): MintelEnv<T> {
const fullSchema = z.object({
...mintelEnvSchema,
...schemaExtension,
@@ -67,8 +72,8 @@ export function validateMintelEnv<T extends z.ZodRawShape>(schemaExtension: T) {
console.warn(
"⚠️ Some environment variables are missing during build, but skipping strict validation.",
);
// Return process.env casted to ensure types match, even if data is missing during build
return process.env as unknown as z.infer<typeof fullSchema>;
// Return process.env casted to the full schema type to unblock builds
return process.env as unknown as MintelEnv<T>;
}
console.error(
@@ -78,5 +83,5 @@ export function validateMintelEnv<T extends z.ZodRawShape>(schemaExtension: T) {
throw new Error("Invalid environment variables");
}
return result.data;
return result.data as MintelEnv<T>;
}