From 32383521cca321a56d22e7b58a2e71c48eea2628 Mon Sep 17 00:00:00 2001 From: "S. Suzuki" Date: Mon, 8 Aug 2022 01:38:47 +0900 Subject: [PATCH] fix(ts): More strict Redirect type (#38277) * fix(ts): More strict Redirect type * lint-fix Co-authored-by: JJ Kasper --- packages/next/lib/load-custom-routes.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/next/lib/load-custom-routes.ts b/packages/next/lib/load-custom-routes.ts index 36a226b81221..caa0e2f8307c 100644 --- a/packages/next/lib/load-custom-routes.ts +++ b/packages/next/lib/load-custom-routes.ts @@ -42,9 +42,16 @@ export type Redirect = { basePath?: false locale?: false has?: RouteHas[] - statusCode?: number - permanent?: boolean -} +} & ( + | { + statusCode?: never + permanent: boolean + } + | { + statusCode: number + permanent?: never + } +) export const allowedStatusCodes = new Set([301, 302, 303, 307, 308]) const allowedHasTypes = new Set(['header', 'cookie', 'query', 'host'])