]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
fix(types): add missing exported types
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 24 Dec 2020 09:45:29 +0000 (10:45 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 24 Dec 2020 09:45:29 +0000 (10:45 +0100)
src/RouterLink.ts
src/history/common.ts
src/index.ts
src/matcher/index.ts
src/router.ts
src/types/index.ts

index da874c786f806c2a9ab8c8d8382efaf89bc734f3..8be402f5c00850ed179d33eeda9ce2bb62179efe 100644 (file)
@@ -56,7 +56,7 @@ export interface RouterLinkProps extends RouterLinkOptions {
     | 'false'
 }
 
-type UseLinkOptions = VueUseOptions<RouterLinkOptions>
+export type UseLinkOptions = VueUseOptions<RouterLinkOptions>
 
 // TODO: we could allow currentRoute as a prop to expose `isActive` and
 // `isExactActive` behavior should go through an RFC
index 3dc320fb9514ac9e44c766c77d011872dad24c9f..b203f17b7f614f7a1499472b48f5a2cb3e0bcd54 100644 (file)
@@ -4,6 +4,9 @@ import { removeTrailingSlash } from '../location'
 export type HistoryLocation = string
 // pushState clones the state passed and do not accept everything
 // it doesn't accept symbols, nor functions as values. It also ignores Symbols as keys
+/**
+ * Allowed variables in HTML5 history state
+ */
 type HistoryStateValue =
   | string
   | number
@@ -13,6 +16,9 @@ type HistoryStateValue =
   | HistoryState
   | HistoryStateArray
 
+/**
+ * Allowed HTML history.state
+ */
 export interface HistoryState {
   [x: number]: HistoryStateValue
   [x: string]: HistoryStateValue
index 8ace025dc0a92eeafe3e155bc4cfbdf641e1a140..370bf17015bca8010e4bb1b5727ab742d91813cb 100644 (file)
@@ -1,7 +1,7 @@
 export { createWebHistory } from './history/html5'
 export { createMemoryHistory } from './history/memory'
 export { createWebHashHistory } from './history/hash'
-export { createRouterMatcher } from './matcher'
+export { createRouterMatcher, RouterMatcher } from './matcher'
 
 export {
   LocationQuery,
@@ -12,7 +12,7 @@ export {
   LocationQueryValueRaw,
 } from './query'
 
-export { RouterHistory } from './history/common'
+export { RouterHistory, HistoryState } from './history/common'
 
 export { RouteRecord, RouteRecordNormalized } from './matcher/types'
 
@@ -30,27 +30,38 @@ export {
 } from './injectionSymbols'
 
 export {
-  RouteMeta,
+  // route location
   _RouteLocationBase,
-  _RouteRecordBase,
+  LocationAsPath,
+  LocationAsRelativeRaw,
+  RouteQueryAndHash,
   RouteLocationRaw,
   RouteLocation,
   RouteLocationNormalized,
   RouteLocationNormalizedLoaded,
-  START_LOCATION_NORMALIZED as START_LOCATION,
   RouteParams,
+  RouteParamValue,
   RouteLocationMatched,
   RouteLocationOptions,
+  RouteRecordRedirectOption,
+  // route records
+  _RouteRecordBase,
+  RouteMeta,
+  START_LOCATION_NORMALIZED as START_LOCATION,
+  RouteComponent,
+  // RawRouteComponent,
+  RouteRecordName,
   RouteRecordRaw,
   NavigationGuard,
   NavigationGuardNext,
+  NavigationGuardWithThis,
   NavigationHookAfter,
 } from './types'
+
 export {
   createRouter,
   Router,
   RouterOptions,
-  ErrorHandler,
   RouterScrollBehavior,
 } from './router'
 
@@ -61,7 +72,12 @@ export {
 } from './errors'
 
 export { onBeforeRouteLeave, onBeforeRouteUpdate } from './navigationGuards'
-export { RouterLink, useLink, RouterLinkProps } from './RouterLink'
+export {
+  RouterLink,
+  useLink,
+  RouterLinkProps,
+  UseLinkOptions,
+} from './RouterLink'
 export { RouterView, RouterViewProps } from './RouterView'
 
 export * from './useApi'
index dd5aa0246da6fac64f86f0af932c6434a9750a88..2b2a0a56db6c9d51a95331d682f140592567b54e 100644 (file)
@@ -18,6 +18,11 @@ import {
 import { warn } from '../warning'
 import { assign, noop } from '../utils'
 
+/**
+ * Internal RouterMatcher
+ *
+ * @internal
+ */
 export interface RouterMatcher {
   addRoute: (record: RouteRecordRaw, parent?: RouteRecordMatcher) => () => void
   removeRoute: {
index 6cf8531f317e3f064c7c3c62fb8354e2640505af..8561d257681ce1ffa002b1a6231e560031b223fd 100644 (file)
@@ -67,7 +67,7 @@ import { addDevtools } from './devtools'
  * Internal type to define an ErrorHandler
  * @internal
  */
-export type ErrorHandler = (error: any) => any
+export type _ErrorHandler = (error: any) => any
 // resolve, reject arguments of Promise constructor
 type OnReadyCallback = [() => void, (reason?: any) => void]
 
@@ -304,7 +304,7 @@ export interface Router {
    *
    * @param handler - error handler to register
    */
-  onError(handler: ErrorHandler): () => void
+  onError(handler: _ErrorHandler): () => void
   /**
    * Returns a Promise that resolves when the router has completed the initial
    * navigation, which means it has resolved all async enter hooks and async
@@ -978,7 +978,7 @@ export function createRouter(options: RouterOptions): Router {
   // Initialization and Errors
 
   let readyHandlers = useCallbacks<OnReadyCallback>()
-  let errorHandlers = useCallbacks<ErrorHandler>()
+  let errorHandlers = useCallbacks<_ErrorHandler>()
   let ready: boolean
 
   /**
index b3a5821415306bffed5325e9823cc7a09c8615c4..26032a7ba6de1a23c088e19047693c0c23e56cb2 100644 (file)
@@ -13,13 +13,24 @@ export type Immutable<T> = {
   readonly [P in keyof T]: Immutable<T[P]>
 }
 
+/**
+ * Type to transform a static object into one that allows passing Refs as
+ * values.
+ * @internal
+ */
 export type VueUseOptions<T> = {
   [k in keyof T]: Ref<T[k]> | T[k] | ComputedRef<T[k]>
 }
 
 export type TODO = any
 
+/**
+ * @internal
+ */
 export type RouteParamValue = string
+/**
+ * @internal
+ */
 export type RouteParamValueRaw = RouteParamValue | number
 export type RouteParams = Record<string, RouteParamValue | RouteParamValue[]>
 export type RouteParamsRaw = Record<
@@ -27,11 +38,17 @@ export type RouteParamsRaw = Record<
   RouteParamValueRaw | RouteParamValueRaw[]
 >
 
-// TODO: document, mark as internal and export intermediate types for RouteLocationRaw
+/**
+ * @internal
+ */
 export interface RouteQueryAndHash {
   query?: LocationQueryRaw
   hash?: string
 }
+
+/**
+ * @internal
+ */
 export interface LocationAsPath {
   path: string
 }
@@ -41,6 +58,9 @@ export interface LocationAsName {
   params?: RouteParams
 }
 
+/**
+ * @internal
+ */
 export interface LocationAsRelativeRaw {
   name?: RouteRecordName
   params?: RouteParamsRaw
@@ -157,9 +177,18 @@ export interface RouteLocationNormalized extends _RouteLocationBase {
   matched: RouteRecordNormalized[] // non-enumerable
 }
 
+/**
+ * Allowed Component in {@link RouteLocationMatched}
+ */
 export type RouteComponent = Component
+/**
+ * Allowed Component definitions in route records provided by the user
+ */
 export type RawRouteComponent = RouteComponent | Lazy<RouteComponent>
 
+/**
+ * Possible values for a user-defined route record's name
+ */
 export type RouteRecordName = string | symbol
 
 /**
@@ -221,6 +250,9 @@ export interface _RouteRecordBase extends PathParserOptions {
  */
 export interface RouteMeta extends Record<string | number | symbol, any> {}
 
+/**
+ * @internal
+ */
 export type RouteRecordRedirectOption =
   | RouteLocationRaw
   | ((to: RouteLocation) => RouteLocationRaw)