From af54da91142e364bedf36087ae915b30c6da6640 Mon Sep 17 00:00:00 2001 From: "S. Suzuki" Date: Sun, 3 Jul 2022 22:40:37 +0900 Subject: [PATCH 1/2] fix(ts): More strict Redirect type --- packages/next/lib/load-custom-routes.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/next/lib/load-custom-routes.ts b/packages/next/lib/load-custom-routes.ts index 36a226b81221..ddd28f3a94d9 100644 --- a/packages/next/lib/load-custom-routes.ts +++ b/packages/next/lib/load-custom-routes.ts @@ -42,9 +42,13 @@ 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']) From c2a27a0f8ed7f5cc10f6c83ec4db880812885089 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Sun, 7 Aug 2022 11:04:14 -0500 Subject: [PATCH 2/2] lint-fix --- packages/next/lib/load-custom-routes.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/next/lib/load-custom-routes.ts b/packages/next/lib/load-custom-routes.ts index ddd28f3a94d9..caa0e2f8307c 100644 --- a/packages/next/lib/load-custom-routes.ts +++ b/packages/next/lib/load-custom-routes.ts @@ -42,13 +42,16 @@ export type Redirect = { basePath?: false locale?: false has?: RouteHas[] -} & ({ - statusCode?: never - permanent: boolean -} | { - statusCode: number - permanent?: never -}) +} & ( + | { + 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'])