chore: fix types for compile issue

This commit is contained in:
Matthew Russell
2023-02-15 11:48:49 -08:00
parent daccb88524
commit 0ffcff2a4c
3 changed files with 17 additions and 11 deletions
@@ -87,7 +87,8 @@ export const useEnvironment = create<EnvStore>((set, get) => ({
const rawVars = compileEnvVars();
const safeVars = EnvSchema.parse(rawVars);
set({ ...safeVars });
} catch (err) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
set({
status: 'failed',
error: t('Error processing the Vega environemnt'),
+14 -5
View File
@@ -1,9 +1,18 @@
import type { ZodIssue, ZodError } from 'zod';
import type { ZodIssue } from 'zod';
import { ZodError } from 'zod';
export const compileErrors = (headline: string, error: ZodError) => {
return error.issues.reduce((acc, issue) => {
return acc + `\n - ${compileIssue(issue)}`;
}, headline);
export const compileErrors = (
headline: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any
) => {
if (error instanceof ZodError) {
return error.issues.reduce((acc, issue) => {
return acc + `\n - ${compileIssue(issue)}`;
}, headline);
}
return `${headline}${error?.message ? `: ${error.message}` : ''}`;
};
const compileIssue = (issue: ZodIssue) => {
@@ -89,10 +89,6 @@ export const validateEnvironment = (
return undefined;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
return compileErrors(
'Error processing the vega app environment',
err,
compileIssue
);
return compileErrors('Error processing the vega app environment', err);
}
};