Skip to content

Commit

Permalink
fix(ts): More strict Redirect type (#38277)
Browse files Browse the repository at this point in the history
* fix(ts): More strict Redirect type

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
terrierscript and ijjk committed Aug 7, 2022
1 parent dc13c12 commit 3238352
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/next/lib/load-custom-routes.ts
Expand Up @@ -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'])
Expand Down

0 comments on commit 3238352

Please sign in to comment.