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 old ts-ignores and extra value in routeInfo #10429

Merged
merged 1 commit into from Feb 5, 2020
Merged
Changes from all commits
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
8 changes: 1 addition & 7 deletions packages/next/next-server/lib/router/router.ts
Expand Up @@ -150,7 +150,6 @@ export default class Router implements BaseRouter {

// Backwards compat for Router.router.events
// TODO: Should be remove the following major version as it was never documented
// @ts-ignore backwards compatibility
this.events = Router.events

this.pageLoader = pageLoader
Expand Down Expand Up @@ -355,7 +354,6 @@ export default class Router implements BaseRouter {
method = 'replaceState'
}

// @ts-ignore pathname is always a string
const route = toRoute(pathname)
const { shallow = false } = options

Expand Down Expand Up @@ -394,7 +392,6 @@ export default class Router implements BaseRouter {
Router.events.emit('routeChangeStart', as)

// If shallow is true and the route exists in the router cache we reuse the previous result
// @ts-ignore pathname is always a string
this.getRouteInfo(route, pathname, query, as, shallow).then(routeInfo => {
const { error } = routeInfo

Expand All @@ -404,7 +401,6 @@ export default class Router implements BaseRouter {

Router.events.emit('beforeHistoryChange', as)
this.changeState(method, url, addBasePath(as), options)
const hash = window.location.hash.substring(1)

if (process.env.NODE_ENV !== 'production') {
const appComp: any = this.components['/_app'].Component
Expand All @@ -413,8 +409,7 @@ export default class Router implements BaseRouter {
!(routeInfo.Component as any).getInitialProps
}

// @ts-ignore pathname is always defined
this.set(route, pathname, query, as, { ...routeInfo, hash })
this.set(route, pathname, query, as, routeInfo)

if (error) {
Router.events.emit('routeChangeError', error, as)
Expand Down Expand Up @@ -658,7 +653,6 @@ export default class Router implements BaseRouter {
return
}

// @ts-ignore pathname is always defined
const route = toRoute(pathname)
this.pageLoader.prefetch(route).then(resolve, reject)
})
Expand Down