From deb9af4cd756b029de986801c7060c99c982ead3 Mon Sep 17 00:00:00 2001 From: Niklas Fischer Date: Sun, 29 Sep 2024 14:13:51 +0200 Subject: [PATCH] Fix zod and SuspenseWithErrorBoundary issues --- src/components/ModuleEditor/index.tsx | 8 ++++---- src/components/SuspenseWithErrorBoundary/index.tsx | 13 ++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/components/ModuleEditor/index.tsx b/src/components/ModuleEditor/index.tsx index e3af88e..94ab3d3 100644 --- a/src/components/ModuleEditor/index.tsx +++ b/src/components/ModuleEditor/index.tsx @@ -58,11 +58,11 @@ function getValues(moduleId: IParams["moduleID"] | null) { //return moduleJSON as IModuleSchema; } else { console.error("Failed to fetch module"); - const obj: Omit & { lang: string } = { + const obj: IModuleSchema = { id: "", name: "", type: "module", - lang: "", + lang: "" as "en" | "de", compatibility: packageJson.version, questions: [], }; @@ -70,12 +70,12 @@ function getValues(moduleId: IParams["moduleID"] | null) { } } -function getDefaultValues() { +function getDefaultValues(): IModuleSchema { return { id: "", name: "", type: "module", - lang: "", + lang: "" as "en" | "de", compatibility: packageJson.version, questions: [], }; diff --git a/src/components/SuspenseWithErrorBoundary/index.tsx b/src/components/SuspenseWithErrorBoundary/index.tsx index ffb29d0..6d3a8ad 100644 --- a/src/components/SuspenseWithErrorBoundary/index.tsx +++ b/src/components/SuspenseWithErrorBoundary/index.tsx @@ -1,4 +1,4 @@ -import { PropsWithChildren, Suspense, SuspenseProps } from "react"; +import { ErrorInfo, PropsWithChildren, Suspense, SuspenseProps } from "react"; import { ErrorBoundary, ErrorBoundaryProps, FallbackProps } from "react-error-boundary"; import { CircularTailSpinner } from "../Spinner"; import { Link, useNavigate } from "react-router-dom"; @@ -125,13 +125,8 @@ export const DefaultFallbackComponent: React.FC = ({ error, reset }; // This type is from react-error-boundary but doesn't get exported -type ErrorBoundarySharedProps = { - onError?: ( - error: Error, - info: { - componentStack: string | null | undefined; - } - ) => void; +type ErrorBoundarySharedProps = PropsWithChildren<{ + onError?: (error: Error, info: ErrorInfo) => void; onReset?: ( details: | { @@ -145,7 +140,7 @@ type ErrorBoundarySharedProps = { } ) => void; resetKeys?: any[]; -}; +}>; /* const LoadingComponent = () => { throw new Promise(() => {});