Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary assertions #38899

Merged
merged 2 commits into from Jul 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/next/shared/lib/router/router.ts
Expand Up @@ -172,7 +172,7 @@ function omit<T extends { [key: string]: any }, K extends keyof T>(
const omitted: { [key: string]: any } = {}
Object.keys(object).forEach((key) => {
if (!keys.includes(key as K)) {
omitted[key as string] = object[key]
omitted[key] = object[key]
}
})
return omitted as Omit<T, K>
Expand Down Expand Up @@ -292,16 +292,16 @@ function prepareUrlAs(router: NextRouter, url: Url, as?: Url) {
}

function resolveDynamicRoute(pathname: string, pages: string[]) {
const cleanPathname = removeTrailingSlash(denormalizePagePath(pathname!))
const cleanPathname = removeTrailingSlash(denormalizePagePath(pathname))
if (cleanPathname === '/404' || cleanPathname === '/_error') {
return pathname
}

// handle resolving href for dynamic routes
if (!pages.includes(cleanPathname!)) {
if (!pages.includes(cleanPathname)) {
// eslint-disable-next-line array-callback-return
pages.some((page) => {
if (isDynamicRoute(page) && getRouteRegex(page).re.test(cleanPathname!)) {
if (isDynamicRoute(page) && getRouteRegex(page).re.test(cleanPathname)) {
pathname = page
return true
}
Expand Down Expand Up @@ -732,7 +732,7 @@ export default class Router implements BaseRouter {
const autoExportDynamic =
isDynamicRoute(pathname) && self.__NEXT_DATA__.autoExport

this.basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''
this.basePath = process.env.__NEXT_ROUTER_BASEPATH || ''
this.sub = subscription
this.clc = null
this._wrapApp = wrapApp
Expand Down