When you enable typescript, the linter complains that afterPageLoad function cannot return void. So you have to add a return true (or false?) in the function.
Argument of type '(page: ClientNodeApi) => void' is not assignable to parameter of type '(page?: ClientNodeApi) => boolean'.
Type 'void' is not assignable to type 'boolean'.ts(2345)
See helper documentation
Other typescript issue ( getDirection (path1, path2)):
$: lastRoute = $route.last
$route is of type never, so typescript won't eat this.