From 43a96e2ac9529da767b40faa60b72076196f1cf1 Mon Sep 17 00:00:00 2001 From: Louis Chan Date: Thu, 19 Dec 2024 14:47:51 +0800 Subject: [PATCH] Ignore a eslint false positive --- portal/src/ErrorBoundSuspense.tsx | 11 +++-------- portal/src/FlavoredErrorBoundSuspense.tsx | 8 ++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/portal/src/ErrorBoundSuspense.tsx b/portal/src/ErrorBoundSuspense.tsx index 208a1345ab..7d3dbccca6 100644 --- a/portal/src/ErrorBoundSuspense.tsx +++ b/portal/src/ErrorBoundSuspense.tsx @@ -7,21 +7,16 @@ import React, { useState, useEffect, } from "react"; -import { ErrorBoundary, ErrorBoundaryProps } from "@sentry/react"; +import { ErrorBoundary, FallbackRender } from "@sentry/react"; export interface ErrorBoundSuspenseProps { - errorBoundaryFallback: NonNullable; + errorBoundaryFallback: FallbackRender; suspenseFallback: SuspenseProps["fallback"]; factory: () => Promise<{ default: React.ComponentType }>; children: (Component: React.ComponentType) => React.ReactNode; } -export interface ErrorBoundaryFallbackProps { - error: unknown; - componentStack: string; - eventId: string; - resetError(): void; -} +export type ErrorBoundaryFallbackProps = Parameters[0]; const extractImportArgRegex = /import\(["']([-_./a-zA-Z0-9]+)["']\)/; diff --git a/portal/src/FlavoredErrorBoundSuspense.tsx b/portal/src/FlavoredErrorBoundSuspense.tsx index 225930fa17..5c39d99ef3 100644 --- a/portal/src/FlavoredErrorBoundSuspense.tsx +++ b/portal/src/FlavoredErrorBoundSuspense.tsx @@ -17,6 +17,14 @@ export interface FlavoredErrorBoundSuspenseProps { function FallbackComponent( props: ErrorBoundaryFallbackProps ): React.ReactElement { + // The definition of resetError is + // resetError(): void; + // instead of + // resetError: () => void; + // This makes TypeScript think it is method that could access this. + // But I think that is just a mistake in the type definition. + // So it should be safe to ignore. + // eslint-disable-next-line @typescript-eslint/unbound-method const { resetError } = props; const onClick = useCallback( (e: React.MouseEvent) => {