From 2eb8ef251e036efff3d5e540639cbb2ce63a43f1 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Thu, 27 Oct 2022 14:27:36 -0700 Subject: [PATCH] Add never return type for redirect() and notFound() --- packages/next/client/components/not-found.ts | 2 +- packages/next/client/components/redirect.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/client/components/not-found.ts b/packages/next/client/components/not-found.ts index e5cad6a30139412..2ca5e894be9bbfa 100644 --- a/packages/next/client/components/not-found.ts +++ b/packages/next/client/components/not-found.ts @@ -1,6 +1,6 @@ export const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND' -export function notFound() { +export function notFound(): never { // eslint-disable-next-line no-throw-literal const error = new Error(NOT_FOUND_ERROR_CODE) ;(error as any).digest = NOT_FOUND_ERROR_CODE diff --git a/packages/next/client/components/redirect.ts b/packages/next/client/components/redirect.ts index 0b500ae87256f3f..5e685f94edbe0d9 100644 --- a/packages/next/client/components/redirect.ts +++ b/packages/next/client/components/redirect.ts @@ -1,6 +1,6 @@ export const REDIRECT_ERROR_CODE = 'NEXT_REDIRECT' -export function redirect(url: string) { +export function redirect(url: string): never { // eslint-disable-next-line no-throw-literal const error = new Error(REDIRECT_ERROR_CODE) ;(error as any).digest = REDIRECT_ERROR_CODE + ';' + url