diff --git a/packages/next/src/client/components/error-boundary.tsx b/packages/next/src/client/components/error-boundary.tsx index 13d87fb40c18e..ad661efaac03c 100644 --- a/packages/next/src/client/components/error-boundary.tsx +++ b/packages/next/src/client/components/error-boundary.tsx @@ -109,7 +109,8 @@ export class ErrorBoundaryHandler extends React.Component< this.setState({ error: null }) } - render() { + // Explicit type is needed to avoid the generated `.d.ts` having a wide return type that could be specific the the `@types/react` version. + render(): React.ReactNode { if (this.state.error) { return ( <> diff --git a/packages/next/src/client/components/redirect-boundary.tsx b/packages/next/src/client/components/redirect-boundary.tsx index f0ee6fad318c4..c4530614895ac 100644 --- a/packages/next/src/client/components/redirect-boundary.tsx +++ b/packages/next/src/client/components/redirect-boundary.tsx @@ -58,7 +58,8 @@ export class RedirectErrorBoundary extends React.Component< throw error } - render() { + // Explicit type is needed to avoid the generated `.d.ts` having a wide return type that could be specific the the `@types/react` version. + render(): React.ReactNode { const { redirect, redirectType } = this.state if (redirect !== null && redirectType !== null) { return ( diff --git a/packages/react-dev-overlay/src/internal/ErrorBoundary.tsx b/packages/react-dev-overlay/src/internal/ErrorBoundary.tsx index 429c7cefa4199..20ffe17f616c6 100644 --- a/packages/react-dev-overlay/src/internal/ErrorBoundary.tsx +++ b/packages/react-dev-overlay/src/internal/ErrorBoundary.tsx @@ -30,7 +30,8 @@ class ErrorBoundary extends React.PureComponent< } } - render() { + // Explicit type is needed to avoid the generated `.d.ts` having a wide return type that could be specific the the `@types/react` version. + render(): React.ReactNode { // The component has to be unmounted or else it would continue to error return this.state.error || (this.props.globalOverlay && this.props.isMounted) ? (