]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
fix: export more types
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 23 Mar 2020 09:55:16 +0000 (10:55 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 23 Mar 2020 09:55:53 +0000 (10:55 +0100)
Closes #137

src/history/common.ts
src/index.ts
src/matcher/index.ts
src/router.ts
src/types/index.ts

index a59b9dd7f8298c0b62a49507f93f5dc354d93975..2269e9b80b6dd1cd97480ccdeb07b5a060e416fa 100644 (file)
@@ -1,4 +1,3 @@
-import { ListenerRemover } from '../types'
 import { LocationQueryRaw, LocationQuery } from '../utils/query'
 
 interface HistoryLocation {
@@ -81,7 +80,7 @@ export interface RouterHistory {
   forward(triggerListeners?: boolean): void
   go(distance: number, triggerListeners?: boolean): void
 
-  listen(callback: NavigationCallback): ListenerRemover
+  listen(callback: NavigationCallback): () => void
   destroy(): void
 }
 
index 8dbeb57e020087438e3718cd5e81961e160f19eb..e7e450e488afd86ad57bdbd253ceffcdf8fbcb29 100644 (file)
@@ -4,14 +4,23 @@ import createWebHashHistory from './history/hash'
 import { inject } from 'vue'
 import { routerKey, routeLocationKey } from './utils/injectionSymbols'
 
+export { LocationQuery, parseQuery, stringifyQuery } from './utils/query'
+
 export { RouterHistory } from './history/common'
 
+export { RouteRecordNormalized } from './matcher/types'
+
 export {
   RouteLocationNormalized,
-  RouteLocationOptions,
+  RouteLocationNormalizedResolved,
   START_LOCATION_NORMALIZED as START_LOCATION,
+  RouteParams,
+  RouteLocationOptions,
+  RouteRecord,
+  NavigationGuard,
+  PostNavigationGuard,
 } from './types'
-export { createRouter, Router, RouterOptions } from './router'
+export { createRouter, Router, RouterOptions, ErrorHandler } from './router'
 
 export { onBeforeRouteLeave } from './navigationGuards'
 export { Link } from './components/Link'
index 1f4e9d6548122c3591b5d350b8fdb71187b48beb..9019df832cd44b332e12f11620f90cad4aa4aca7 100644 (file)
@@ -2,7 +2,6 @@ import {
   RouteRecord,
   MatcherLocation,
   MatcherLocationNormalized,
-  ListenerRemover,
 } from '../types'
 import { createRouterError, ErrorTypes, MatcherError } from '../errors'
 import { createRouteRecordMatcher, RouteRecordMatcher } from './path-matcher'
@@ -16,10 +15,7 @@ import {
 let noop = () => {}
 
 interface RouterMatcher {
-  addRoute: (
-    record: RouteRecord,
-    parent?: RouteRecordMatcher
-  ) => ListenerRemover
+  addRoute: (record: RouteRecord, parent?: RouteRecordMatcher) => () => void
   removeRoute: {
     (matcher: RouteRecordMatcher): void
     (name: Required<RouteRecord>['name']): void
index 5c71d773a5dd37bda81b3c441d485cf8bdcf520a..161561cba4403b0eb5daf2cf1a385e7b1c3b93d8 100644 (file)
@@ -3,7 +3,6 @@ import {
   RouteRecord,
   RouteLocation,
   NavigationGuard,
-  ListenerRemover,
   PostNavigationGuard,
   START_LOCATION_NORMALIZED,
   Lazy,
@@ -40,7 +39,11 @@ import { Link } from './components/Link'
 import { View } from './components/View'
 import { routerKey, routeLocationKey } from './utils/injectionSymbols'
 
-type ErrorHandler = (error: any) => any
+/**
+ * Internal type to define an ErrorHandler
+ * @internal
+ */
+export type ErrorHandler = (error: any) => any
 // resolve, reject arguments of Promise constructor
 type OnReadyCallback = [() => void, (reason?: any) => void]
 
@@ -75,10 +78,10 @@ export interface Router {
   push(to: RouteLocation): Promise<RouteLocationNormalizedResolved>
   replace(to: RouteLocation): Promise<RouteLocationNormalizedResolved>
 
-  beforeEach(guard: NavigationGuard<undefined>): ListenerRemover
-  afterEach(guard: PostNavigationGuard): ListenerRemover
+  beforeEach(guard: NavigationGuard<undefined>): () => void
+  afterEach(guard: PostNavigationGuard): () => void
 
-  onError(handler: ErrorHandler): ListenerRemover
+  onError(handler: ErrorHandler): () => void
   isReady(): Promise<void>
 
   install(app: App): void
index 12c3f5954e56ce465f4389cdfdf2f69f7b4b6944..2e49b347673d2021222a29f5ab2db8d1bc955d32 100644 (file)
@@ -12,8 +12,6 @@ export type Immutable<T> = {
 
 export type TODO = any
 
-export type ListenerRemover = () => void
-
 export type RouteParamValue = string
 // TODO: should we allow more values like numbers and normalize them to strings?
 // type RouteParamValueRaw = RouteParamValue | number
@@ -38,7 +36,7 @@ export interface LocationAsName {
 }
 
 export interface LocationAsRelative {
-  params?: RouteParams
+  params?: RouteParamsRaw
 }
 
 export interface RouteLocationOptions {