Unverified Commit d034fff6 authored by Yuddomack's avatar Yuddomack Committed by GitHub

Remove unnecessary assertions (#38899)

removed unnecessary assertions of variables to prevent misuse

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
parent 5c8a5b64
...@@ -172,7 +172,7 @@ function omit<T extends { [key: string]: any }, K extends keyof T>( ...@@ -172,7 +172,7 @@ function omit<T extends { [key: string]: any }, K extends keyof T>(
const omitted: { [key: string]: any } = {} const omitted: { [key: string]: any } = {}
Object.keys(object).forEach((key) => { Object.keys(object).forEach((key) => {
if (!keys.includes(key as K)) { if (!keys.includes(key as K)) {
omitted[key as string] = object[key] omitted[key] = object[key]
} }
}) })
return omitted as Omit<T, K> return omitted as Omit<T, K>
...@@ -292,16 +292,16 @@ function prepareUrlAs(router: NextRouter, url: Url, as?: Url) { ...@@ -292,16 +292,16 @@ function prepareUrlAs(router: NextRouter, url: Url, as?: Url) {
} }
function resolveDynamicRoute(pathname: string, pages: string[]) { function resolveDynamicRoute(pathname: string, pages: string[]) {
const cleanPathname = removeTrailingSlash(denormalizePagePath(pathname!)) const cleanPathname = removeTrailingSlash(denormalizePagePath(pathname))
if (cleanPathname === '/404' || cleanPathname === '/_error') { if (cleanPathname === '/404' || cleanPathname === '/_error') {
return pathname return pathname
} }
// handle resolving href for dynamic routes // handle resolving href for dynamic routes
if (!pages.includes(cleanPathname!)) { if (!pages.includes(cleanPathname)) {
// eslint-disable-next-line array-callback-return // eslint-disable-next-line array-callback-return
pages.some((page) => { pages.some((page) => {
if (isDynamicRoute(page) && getRouteRegex(page).re.test(cleanPathname!)) { if (isDynamicRoute(page) && getRouteRegex(page).re.test(cleanPathname)) {
pathname = page pathname = page
return true return true
} }
...@@ -732,7 +732,7 @@ export default class Router implements BaseRouter { ...@@ -732,7 +732,7 @@ export default class Router implements BaseRouter {
const autoExportDynamic = const autoExportDynamic =
isDynamicRoute(pathname) && self.__NEXT_DATA__.autoExport 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.sub = subscription
this.clc = null this.clc = null
this._wrapApp = wrapApp this._wrapApp = wrapApp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment